Open jdf-id-au opened 6 years ago
I have the exact same issue. Cannot start a REPL in Cursive when using lein-v. I get the same output:
10.25 Error running 'REPL for sinostudy': src/cljc/version.cljc (No such file or directory)
I found a (not very good) workaround which is to set an absolute path instead. In my case it looks like:
:prep-tasks [["v" "cache" "/Users/simongray/Code/sinostudy/src/cljc" "cljc"]]
Here's a version that builds the absolute path dynamically. It should work for any user.
:prep-tasks [["v" "cache" ~(str (.getCanonicalPath (clojure.java.io/file ".")) "/src/cljc") "cljc"]]
Unfortunately, lein-v doesn't seem to agree with the absolute path set in this workaround, so the version in version.cljc is reset to "0.0.0" which I find very strange. In my case, I can keep the relative path for the release version which doesn't need a REPL and use this generated absolute path to make Cursive happy, with the unfortunate result that the version will display "0.0.0" while developing, but it should be the correct one when making a release.
To avoid @simongray's condition, I use
:prep-tasks [~(when (System/getenv "PWD") ["v" "cache" "resources" "edn"])]
This avoids running the prep task if there's no PWD
set yet (for some reason) at that point in the configuration execution. The actual working directory is where the IntelliJ binary is (e.g. /Applications/IntelliJ IDEA.app/Contents/bin/
).
When lein is run from the command line, the prep task is run.
The consequence is that the version when running in the IDE is whatever it was set to when lein was last run from the command line. To fix that, run a leiningen configuration as "Before launch" item in your REPL configuration. Assuming a module named "foo" in a directory named "foo" under your project root (remove if you don't have multiple modules):
.idea/runConfigurations/REPL_foo.xml
:
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="REPL foo" type="ClojureREPL" factoryName="Local" singleton="true">
<module name="foo" />
<setting name="replType" value="1" />
<setting name="jvmArgs" value="" />
<setting name="parameters" value="" />
<setting name="workingDir" value="$PROJECT_DIR$/foo" />
<setting name="profiles" value="" />
<method v="2">
<option name="RunConfigurationTask" enabled="true" run_configuration_name="lein-v foo" run_configuration_type="LeiningenRunConfiguration" />
</method>
</configuration>
</component>
.idea/runConfigurations/lein_v_foo.xml
:
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lein-v foo" type="LeiningenRunConfiguration" factoryName="Leiningen" singleton="true">
<module name="foo" />
<arguments argument="v" />
<arguments argument="cache" />
<arguments argument="resources" />
<arguments argument="edn" />
<setting name="profiles" value="" />
<setting name="trampoline" value="false" />
<method v="2" />
</configuration>
</component>
PS: just an additional note that these XML files are "shareable" with others in your team because I explicitly edit the workingDir
to use $PROJECT_DIR$
. This stops the plugin re-writing it to an absolute path that probably is only valid on your local machine but keeps it the same effective value.
Hi,
I'm having a similar issue, running "lein v cache ..." inside a lein monolith setup, i.e. the "lein v cache" is supposed to run on a subproject in a different directory.
Currently that fails, because the path is relative to the current working directory (which I assume is the same problem for Cursive). Actually, the path should instead be relative to leiningen.core.eval/*dir*
. This is set correctly by lein monolith and (I assume) by Cursive.
I've just fixed this in Cursive, so it should work without workarounds now. It's a change to a fairly sensitive part of the lein integration so it will probably be in the next release cycle (1.10.2).
Thanks for a great plugin.
It works for me with
:prep-tasks [["v" "cache" "src" "edn"]]
but only from the command linelein repl
.When I run a plain repl in Cursive ("Run nREPL with Leiningen"), the IDE gives "src/version.edn (No such file or directory)". This happens even if I
touch
that file beforehand. The IDE is otherwise working normally.I have no idea where to start looking to help fix this. Help!