Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SBT publishing via SSH key auth not working #738

Closed
jaytaylor opened this issue Apr 22, 2013 · 5 comments
Closed

SBT publishing via SSH key auth not working #738

jaytaylor opened this issue Apr 22, 2013 · 5 comments
Labels
needs info Needs more information to take further actions.

Comments

@jaytaylor
Copy link
Contributor

This originally began as a StackOverflow question, see: http://stackoverflow.com/questions/16136511/sbt-publishing-via-ssh-key-auth-not-working. However, at this point it seems like it is probably not a mis-configuration and seems like it's being caused by the version of ivy being used by SBT (currently ivy-2.2.0).

My question is: Why can't I publish from SBT to my server via SSH?

Context:

I am developing a scala library and I want to publish it to a remote repository with SBT v0.12.3 over SSH (using an SFTP resolver). The relevant portion of my project/Build.scala SBT settings file is configured as prescribed by https://github.com/harrah/xsbt/wiki/Resolvers:

publishTo <<= version { v =>
    Some(Resolver.sftp(
        "My Repository",
        "example.com",
        "/var/www/public_html/repositories/" + (
            if (v.trim.endsWith("SNAPSHOT")) { "snapshots" } else { "releases" }
        )
    ))
},
resolvers ++= Seq(
    {
        import java.io.File
        val privateKeyFile: File = new File(sys.env("HOME") + "/.ssh/id_rsa")
        Resolver.ssh("scala-sh", "example.com") as("my-username", privateKeyFile) withPermissions("0644")
    },
    ...
),

When I run sbt publish, things go fine until the authorization, where it still attempts to prompt me for login/password. When I run it locally, it brings up the username/password prompt, and when I try to publish remotely while SSH'd in to a machine it fails with a java.awt.HeadlessException. The result appears to be that the desired private-key type of authentication is not being attempted.

Here is a log of the remote session publish attempt:

> sbt-version
[info] 0.12.3

> publish
[info] Packaging /home/me/my-lib/target/scala-2.10.1/my-lib_2.10.1-SNAPSHOT-sources.jar ...
[info] Done packaging.
[info] Wrote /home/me/my-lib/target/scala-2.10.1/my-lib_2.10.1-SNAPSHOT.pom
[info] :: delivering :: org.example#my-lib_2.10.1;SNAPSHOT :: SNAPSHOT :: release :: Sun Apr 21 12:48:59 PDT 2013
[info]  delivering ivy file to /home/me/my-lib/target/scala-2.10.1/ivy-SNAPSHOT.xml
[info] Generating API documentation for main sources...
model contains 75 documentable templates
[info] API documentation generation successful.
[info] Packaging /home/me/my-lib/target/scala-2.10.1/my-lib_2.10.1-SNAPSHOT-javadoc.jar ...
[info] Done packaging.
[info] Packaging my-lib-SNAPSHOT.jar ...
[info] Done packaging.
[trace] Stack trace suppressed: run last *:publish for the full output.
[error] (*:publish) java.awt.HeadlessException:
[error] No X11 DISPLAY variable was set, but this program performed an operation which requires it.
[error] Total time: 35 s, completed Apr 21, 2013 12:49:33 PM

It fails because there is no X11 display. This is unexpected behavior because the SBT project configuration is set to use private key authentication (see resolvers above).

So far I can think of 2 possible causes for the problem, detailed below.

Possible cause #1: Misconfiguration of SBT

Is there a problem in my configuration above?

Possible cause #2: Hitting an Ivy bug from an old version

At time of writing, I am using the latest SBT, 0.12.3. Maybe the version of Ivy being used by SBT is old. The more I think about it, the less likely this seems, but I haven't been able to rule it out yet.

How can I find out what version of Ivy SBT is using?

and then..

IF it is old, is there a way to get SBT to use a newer version of ivy?

There is another relevant question, see http://stackoverflow.com/q/12486604/293064, which references[0] an Old Ivy bug which caused java.awt.HeadlessExceptions.

[0] http://stackoverflow.com/q/12486604/293064

  • "Which version of Ivy are you using? There is a Jira Bug for Version 2.0 : issues.apache.org/jira/browse/IVY-783 which should be fixed now."
  • "Seems like if I upgrade to ivy 2.3 rc-2. SSH publish works."
@jaytaylor
Copy link
Contributor Author

I'm really keen on getting past this problem. Is this there a better place to ask this question?

@harrah
Copy link
Member

harrah commented May 1, 2013

sbt 0.12.3 uses Ivy 2.3.0-rc1. I don't see anything in the Ivy issue tracker that makes it look like rc2 fixes any ssh problems in rc1.

I don't know if it matters, but you resolve from a repository configured from a base path and using sftp, but publish to one without a base path and with ssh.

@eed3si9n
Copy link
Member

eed3si9n commented Apr 2, 2014

sbt 0.13.2-RC1 uses Ivy 2.3.0. Do you wanna give it a try to see if this still happens?

@eed3si9n
Copy link
Member

Closing this for now. Feel free to reopen if the problem persists with the latest sbt.

@jaytaylor
Copy link
Contributor Author

Thanks Eugene, I tried this again recently and it seemed to be working okay.

On Tue, Jun 24, 2014 at 11:06 AM, eugene yokota notifications@github.com
wrote:

Closing this for now. Feel free to reopen if the problem persists with the
latest sbt.


Reply to this email directly or view it on GitHub
#738 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs info Needs more information to take further actions.
Projects
None yet
Development

No branches or pull requests

3 participants