Skip to content

Clojure CLI command parameters order incorrect #2916

@practicalli-johnny

Description

@practicalli-johnny

EDIT: cider-clojure-cli-aliases should be used instead of cider-clojure-cli-global-options and execution flags should not be included in the value, only the alias name (keyword, e.g. ":env/test") or names (keword chain, e.g. ":env/test:lib/reloaded")

The order of the arguments to the Clojure CLI tools command does not follow the documentation. It seems the -A flag (being deprecated) did allow the command to work with arguments out of sequence, however the -M does not.

Suggest updating the generation of the clojure command line to follow the documented order of arguments
clojure [clj-opt*] -M[:aliases] [init-opt*] [main-opt] [arg*]

Another approach would be to document a variable that can be used in the .dir-locals.el to disable the -Sdeps argument completely and require the Clojure CLI tools alias to provide the required libraries as an alias.

Expected behavior

Use a .dir-locals.el file to set the cider-clojure-cli-global-options to include an alias using the -M flag of the clojure command

((clojure-mode . ((cider-preferred-build-tool . "clojure-cli")
                           (cider-clojure-cli-global-options . "-M:env/test"))))

Open a Clojure project that is configured with deps.edn and run cider-jack-in and a REPL process should start using Clojure CLI tools, which cider then connects to.

The command line used by cider-jack-in-clj should place the -M:env/test argument after the -Sdeps argument and before the -m argument on the clojure command line

/usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.8.2"} refactor-nrepl {:mvn/version "2.5.0"} cider/cider-nrepl {:mvn/version "0.25.3"}}}' -M:env/test -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware"]'

Actual behavior

An error occurs and the REPL does not start

error in process sentinel: Could not start nREPL server: Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
-Sdeps (No such file or directory)

The clojure command line puts the -M:env/test argument before the -Sdeps argument, causing the error.

/usr/local/bin/clojure -M:env/test -Sdeps '{:deps {nrepl {:mvn/version "0.8.2"} refactor-nrepl {:mvn/version "2.5.0"} cider/cider-nrepl {:mvn/version "0.25.3"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware"]'

Steps to reproduce the problem

Install Clojure CLI tools, version 1.10.1.679 or greater, following the Linux or Homebrew instructions on https://clojure.org/guides/getting_started#_clojure_installer_and_cli_tools

Clone this example Clojure project that demonstrates the issue, with an -M:env/test argument set in the .dir-locals.el file.
https://github.com/practicalli/four-clojure

Open the project in Emacs and call cider-jack-in-clj

The error should appear in the mini-buffer and in the messages buffer

Environment & Version information

CIDER version information

From cider-version:
CIDER 1.0.0snapshot (package: 20200930.1242)

From cider-display-connection-info:

CLJ four-clojure@localhost:46803 (Java 11.0.8, Clojure 1.10.1, nREPL 0.8.2)

Emacs version

GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2020-09-19

Operating system

Ubuntu Linux 20.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issueA simple tasks suitable for first-time contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions