Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should the SBT credentials configuration go?

Tags:

sbt

I'm running SBT 1.1.1 on Windows.

If I put the following line in my build.sbt, my build is OK:

credentials += Credentials(Path.userHome / ".sbt" / ".credentials")

The trouble is, I don't particularly want to leave this kind of machine-specific configuration in my project. Also, in order to use g8 templates I need to have a working global config.

But if I put the same text in a file called credentials.sbt in the following directories it seems not to work.

  • %USERPROFILE%/.sbt/1.1/plugins/credentials.sbt
  • %USERPROFILE%/.sbt/1.1/credentials.sbt
  • %USERPROFILE%/.sbt/plugins/credentials.sbt

So where should this file go?

Whichever location I put the file in I get the following errors:

C:\workspace\tmp>c:\apps\sbt-1.1.1\bin\sbt.bat new sbt/scala-seed.g8
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading settings from credentials.sbt ...
[info] Loading global plugins from C:\Users\NBKA0O5\.sbt\1.0\plugins
[info] Updating ProjectRef(uri("file:/C:/Users/NBKA0O5/.sbt/1.0/plugins/"), "global-plugins")...
[error] Unable to find credentials for [Artifactory Realm @ artifactory.company.com].
[error] Unable to find credentials for [Artifactory Realm @ artifactory.company.com].

I know that my credentials must be good because I use the exact same credentials to boot SBT in the first place.

Bizarrely, even though I'm running sbt-1.1.1 it seems to be wanting to load plugins from %USERPROFILE%\.sbt\1.0\plugins - which makes very little sense to me, the version numbers do not match. Even though I know the file is being read I still get the error messages.

like image 522
Salim Fadhley Avatar asked Mar 08 '18 13:03

Salim Fadhley


1 Answers

Bizarrely, even though I'm running sbt-1.1.1 it seems to be wanting to load plugins from %USERPROFILE%.sbt\1.0\plugins - which makes very little sense to me, the version numbers do not match.

See sbt/sbt#3858 about this issue. You should put your credentials file in ~/.sbt/1.0/credentials.sbt (same as any other global settings).

Also notice that credentials is a task since sbt 1.0, so in case you will have to store your actual credentials somewhere else (environment variables or parse from another file), it should be reevaluated every time it's being used.

like image 139
laughedelic Avatar answered Jan 04 '23 01:01

laughedelic