17

I followed the official documentation to set up the plugin in my sbt project:

  1. Added addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0") to ~/.sbt/plugins/plugins.sbt file
  2. cded to a project and ran sbt
  3. In sbt shell, typed eclipse

That's where I faced the following error:

> eclipse
[error] Not a valid command: eclipse (similar: help, alias)
[error] Not a valid project ID: eclipse (similar: sbteclipse)
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: eclipse (similar: deliver, licenses, clean)
[error] eclipse
[error]        ^

What am I missing?

Thanks in advance for any help you can give me.

$ /opt/sbt-0.13.5/bin/sbt
[warn] The global sbt directory is now versioned and is located at /Users/first.last/.sbt/0.13.
[warn]   You are seeing this warning because there is global configuration in /Users/first.last/.sbt but not in /Users/first.last/.sbt/0.13.
[warn]   The global sbt directory may be changed via the sbt.global.base system property.
[info] Loading project definition from /Users/first.last/git/myproject/project
[info] Set current project to myproject (in build file:/Users/first.last/git/myproject/)
> eclipse
[error] Not a valid command: eclipse (similar: help, alias)
[error] Not a valid project ID: eclipse
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: eclipse (similar: deliver, licenses, clean)
[error] eclipse
[error]        ^
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
Classified
  • 5,759
  • 18
  • 68
  • 99
  • I ran into this error, also. I later discovered it was because I was in the `project` directory. Solved via `cd ..` _facepalm_ – LexH May 07 '19 at 21:34

8 Answers8

23

I'm using sbt 0.13.5.

$ sbt --version
sbt launcher version 0.13.5

In an empty directory executed sbt about to check the build/sbt setup.

$ sbt about
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Updating {file:/Users/jacek/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to sbteclipse (in build file:/Users/jacek/sandbox/sbteclipse/)
[info] This is sbt 0.13.5
[info] The current project is {file:/Users/jacek/sandbox/sbteclipse/}sbteclipse 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.4
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, net.virtualvoid.sbt.graph.Plugin, com.timushev.sbt.updates.UpdatesPlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.4

No files are in the directory (disregard target since it's automatically created by sbt upon startup and can be removed at any time).

$ tree
.
`-- target

1 directory, 0 files

I then ran the sbt shell with sbt to ensure no eclipse command existed.

$ sbt
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Set current project to sbteclipse (in build file:/Users/jacek/sandbox/sbteclipse/)
> eclipse
[error] Not a valid command: eclipse (similar: help, alias)
[error] Not a valid project ID: eclipse (similar: sbteclipse)
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: eclipse (similar: deliver, licenses, clean)
[error] eclipse
[error]        ^

I could reproduce your issue. Moving on to setting up the plugin - I did not close the sbt shell.

Following the documentation closely I opened ~/.sbt/0.13/plugins/plugins.sbt to have it as follows:

$ cat ~/.sbt/0.13/plugins/plugins.sbt
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")

With the plugin in the file, I fired reload in the sbt shell to load the changes.

> reload
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Updating {file:/Users/jacek/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to sbteclipse (in build file:/Users/jacek/sandbox/sbteclipse/)
> eclipse
[info] About to create Eclipse project files for your project(s).
[info] Updating {file:/Users/jacek/sandbox/sbteclipse/}sbteclipse...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Successfully created Eclipse project files for project(s):
[info] sbteclipse

As you can see the plugin was properly loaded and generated the files. Follow the steps and you should have the plugin installed with no issues.

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
  • @Jacek Laskowski, I'm trying to understand which interpreter did you run your commands in. For example, the first one `sbteclipse sbt --version` - is it typed in shell (`bash`, `cmd`, etc.)? Or is it typed in `sbt`? If I type `sbteclipse` in shell, it is not in my path (in fact, I don't think it is anywhere as executable file on my filesystem). If I type it inside `sbt`, I get the same error `[error] Not a valid command: sbteclipse` as with `eclipse` command. I'm on Linux = F23, `sbt` = 0.13, Scala = 2.10.4. And it seems like no other answers are applicable to resolve my problem. – uvsmtid Jun 08 '16 at 15:49
  • I apologize for using the "weird" prompt. Fixed. – Jacek Laskowski Jun 09 '16 at 06:45
5

For sbt 0.13 and up

Add sbteclipse to your plugin definition file. You can use either:

  1. the global file (for version 0.13 and up) at ~/.sbt/0.13/plugins/plugins.sbt

  2. the project-specific file at PROJECT_DIR/project/plugins.sbt

    addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")
    
zinking
  • 5,561
  • 5
  • 49
  • 81
  • I wasn't able to get method #2 to work. I'm not sure why. [error] Not a valid command: eclipse (similar: help, alias) [error] Not a valid project ID: eclipse [error] Expected ':' (if selecting a configuration) [error] Not a valid key: eclipse (similar: deliver, licenses, clean) [error] eclipse [error] ^ – Foo L Jan 15 '15 at 23:10
4

The warning in lines 2-4 is telling you to move your plugins folder from ~/.sbt/plugins/plugins.sbt to ~/.sbt/0.13/plugins/plugins.sbt.

Karl Higley
  • 365
  • 2
  • 6
2

Eclipse doesn't have sbt plugin, although sbt has an eclipse plugin

which is a workaround but not proper solution.

which means eclipse doesnt understand build.sbt as it does for pom.xml or build.gradle so if we change a dependency in our eclipse project in build.sbt file, eclipse will not understand it, and will not change the dependency in the project dependencies.So you have to do the below steps everytime u modify any dependency.

The workaround is as follows(I used windows)

Step1: Download and install sbt from https://www.scala-sbt.org/release/docs/Setup.html for windows it is pretty straight forward https://piccolo.link/sbt-1.2.8.msi pretty straight forward

Step2: Create a folder say D:\sbt\edge now create a build.sbt file here You can use the following as the content, change it accordingly

name := "edge"
version := "0.1"
scalaVersion := "2.11.8"
val sparkVersion="2.4.0"
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % sparkVersion,
"org.apache.spark" %% "spark-sql" % sparkVersion,
"org.apache.spark" %% "spark-mllib" % sparkVersion % "runtime",
"org.apache.spark" %% "spark-streaming" % sparkVersion % "provided",
"org.apache.spark" %% "spark-hive" % sparkVersion % "provided",
"org.apache.spark" %% "spark-catalyst" % sparkVersion % Test,
"org.apache.spark" %% "spark-graphx" % sparkVersion,
"org.apache.spark" %% "spark-repl" % sparkVersion % "provided",
"org.apache.spark" %% "spark-yarn" % sparkVersion,
"org.apache.spark" %% "spark-mllib-local" % sparkVersion,
//"org.apache.spark" %% "spark-streaming-kafka" % "1.6.3",
//"org.apache.spark" %% "spark-streaming-twitter" % "1.6.3",
"ch.qos.logback" % "logback-classic" % "1.1.3"
)

now create these nested folders src and main like -> D:\sbt\spark\src\main

Step3: Open CMD/PowerShell go to D:\sbt\edge run "sbt package"

Step4: Go inside .sbt in ur home directory and in plugins folder of the correct version in my case C:\Users\xxxx.sbt\1.0\plugins if u have a plugins.sbt file already, add the following line addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4") if not, create and add the line.

Step5: Go back to CMD/PowerShell , run sbt eclipse. It will create the necessary files for eclipse project. Step6: Open an eclipse workspace, and import this project as an existing project.

Koushik Paul
  • 995
  • 9
  • 13
1

Solution

Simply update to the latest sbt (sbt-0.13.9-1.noarch in my case) using original documentation (for F23 in my case):

curl https://bintray.com/sbt/rpm/rpm \
  | sudo tee /etc/yum.repos.d/bintray-sbt-rpm.repo

sudo yum install --best --allowerasing sbt

And try again from the project directory (it took ~10 mins to get dependencies the first time):

sbt eclipse

Original Problem

It seems like a problem of (at least ) sbt-0.13.1 on (at least) Linux.

I used default packages on Linux F23:

  • scala-2.10.4-8.fc23.noarch
  • java-1.8.0-openjdk-1.8.0.91-6.b14.fc23.x86_64
  • sbt-0.13.1-8.fc23.noarch

And no permutations ( ~/.sbt/plugins/plugins.sbt, ~/.sbt/0.13/plugins/plugins.sbt, PROJECT_DIR/project/plugins.sbt, ...) with configuration options worked.

uvsmtid
  • 4,187
  • 4
  • 38
  • 64
0

I am using sbt 0.13.13 and I used the below steps to upload sbtecipse. GO to your project. under enter image description here

And then go to project folder from command prompt and sbt

0

to create your sbt project on scala eclipse you need to few things:

  1. create a new project
  2. add folders structure in the project
  3. go to the terminal, through cd command go to your project,
  4. type sbt, then it starts downloading, after that
  5. go to project see, is there any project folder made or not
  6. under that folder create plugin.sbt and add sbt (addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.13") addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")
  7. then go to terminal again type compile den eclipse
  8. it's done, it show a success message
Piotr Labunski
  • 1,638
  • 4
  • 19
  • 26
v_d123
  • 29
  • 6
-1

I was able to get rid of same error by downgrading sbteclipse-plugin form 4.0 to 2.5.0