Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo runs from the wrong directory #31

Closed
dsvensson opened this issue Dec 19, 2016 · 2 comments
Closed

cargo runs from the wrong directory #31

dsvensson opened this issue Dec 19, 2016 · 2 comments

Comments

@dsvensson
Copy link

(cargo-process--project-root) returns the directory of Cargo.toml, but cargo is not run from that directory, which messes up cargo clippy for example:

src> cargo clippy
thread 'main' panicked at 'could not find matching package', /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/option.rs:715
note: Run with `RUST_BACKTRACE=1` for a backtrace.
@wjlroe
Copy link

wjlroe commented Dec 27, 2016

Until this mode gets updated/changed in any way, you can get the bahaviour you need using the following elisp in your config:

  (defun my-set-default-dir-cargo-run (orig-fun &rest args)
    (let* ((project-root (cargo-process--project-root))
           (default-directory (if project-root
                                  project-root
                                default-directory)))
      (apply orig-fun args)))

  (advice-add 'cargo-process--start :around #'my-set-default-dir-cargo-run)

That snippet will run any cargo command in a scope that includes default-directory set to the project root (if that can be resolved).

@kwrooijen
Copy link
Owner

I've applied the change here: 1565746

I've tested it and it seems to be running the command from the root directory now. If you're having any more issues please open a new ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants