4

I am trying to run sbt behind a firewall, and there is no way I can disable it. But somehow I can get the required jars and store them on the system. Is there a way I can run sbt without internet connection on that system.

I am using Windows (Win7) as the development environment.

Jacek Laskowski
  • 68,975
  • 24
  • 224
  • 395
Chetan Kothari
  • 681
  • 1
  • 5
  • 12
  • Checked that now. Actually it was a little bit tricky to find out what exactly the problem was. Later on when i was exploring the same, i came to know that the problem was with the proxy. – Chetan Kothari Mar 28 '14 at 01:47

2 Answers2

3

SBT has an offline mode, from a command line you can use:

sbt "set offline := true" run (replacing run with whatever command you need)

or if you ran sbt and are in a sbt console you can simply do set offline := true

frostmatthew
  • 3,110
  • 4
  • 39
  • 49
  • 1
    I cant even run sbt for the first time so where do i keep the required jars and which are the jars required for first run. – Chetan Kothari Mar 26 '14 at 13:48
  • 1
    Simply add the jars to the lib folder - you may want to read the section on [unmanaged dependencies](http://www.scala-sbt.org/release/docs/Getting-Started/Library-Dependencies.html) from sbt's documentation. – frostmatthew Mar 26 '14 at 14:23
  • Once we have the SBT running, there should be no problem, but how do I start SBT without internet is my problem. I mean I've just setup SBT now when I try to start it, it tries to get some jars from maven or ivy but since i don't have internet i can't even start SBT. – Chetan Kothari Mar 27 '14 at 03:20
  • @ChetanKothari it isn't any different the _first_ time as any other, open a command prompt and type `sbt "set offline := true" run` (replacing _run_ with whatever command you want, e.g. _console_) – frostmatthew Mar 27 '14 at 04:12
  • Tried doing the same but I am unable to enter into SBT console itself. The error i get is `Error: Could not retrieve jansi 1.11` – Chetan Kothari Mar 27 '14 at 04:13
  • @ChetanKothari from the Windows command prompt (where you are presumably entering just `sbt`) enter `sbt "set offline := true" console` this will open an sbt console in offline mode. – frostmatthew Mar 27 '14 at 04:16
  • No luck, This is what I get ```C:\Users\proj1>sbt "set offline := true" console Getting org.fusesource.jansi jansi 1.11 ... You probably access the destination server through a proxy server that is not well configured. ...``` – Chetan Kothari Mar 27 '14 at 04:35
  • 1
    @ChetanKothari OK good, you're definitely running it correctly. Looks like you're missing some dependencies. If you have access to a Windows machine that _does_ have internet access I would suggest checking the location of **jansi-1.11.jar** there and copying the file to the appropriate location on the firewalled machine (it _may_ just need to be on the CLASSPATH, not the exact location). You'll need to repeat this for any other similar errors, but not much else you can do if sbt is missing dependencies and unable to grab them itself. – frostmatthew Mar 27 '14 at 04:49
  • Thanks, but unfortunately I don't have a system that has the firewall disabled, all the machines out here are behind a firewall which blocks the access to those sites via sbt but I can access them directly and download them as well. But the only thing I am not able to understand is where to place them and how. – Chetan Kothari Mar 27 '14 at 04:53
1

I finally found the answer to the question after struggling for two days. The problem was not with the firewall but with the proxy set up. What I had to do was pass the proxy, username and password via command prompt so that it could get the necessary jars.

java -Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080 -Dhttp.proxyUser=proxyUsername -Dhttp.proxyPassword=proxyPassword -cp "/sbt-launch.jar" xsbt.boot.Boot

I ran this piece of code and it solved my problem.

The jars that are downloaded are stored in the .ivy/cache/ path.

Thank you @Exupery for your help.

Chetan Kothari
  • 681
  • 1
  • 5
  • 12