GithubHelp home page GithubHelp logo

Comments (5)

bjc avatar bjc commented on August 29, 2024

Looking into this further, the problem appears to be here: https://github.com/kwrooijen/cargo.el/blob/master/cargo-process.el#L349

    (let ((default-directory (or (cargo-process--workspace-root)
                                 default-directory)))

default-directory is computed properly (/ssh:user@host:/some/path), but cargo-process--workspace-root is returning just the host-local portion (/some/path), and because it comes first in the or, that's what's being used by the call to compilation-start.

So I swapped the order of the arguments, which lead to an issue in manifest-path-argument, where it outputs the TRAMP version of a file for use by cargo itself (which obviously isn't TRAMP aware). The issue is here: https://github.com/kwrooijen/cargo.el/blob/master/cargo-process.el#L321

(defun manifest-path-argument (name)
  (let ((manifest-filename (cargo-process--project-root "Cargo.toml")))
    (when (and manifest-filename
               (not (member name cargo-process--no-manifest-commands)))
      (concat "--manifest-path " (shell-quote-argument manifest-filename)))))

I surrounded the call to cargo-process--project-root with a call to tramp-file-local-name:

(defun manifest-path-argument (name)
  (let ((manifest-filename (tramp-file-local-name (cargo-process--project-root "Cargo.toml"))))
    (when (and manifest-filename
               (not (member name cargo-process--no-manifest-commands)))
      (concat "--manifest-path " (shell-quote-argument manifest-filename)))))

And now it returns the system-local version of the file name, suitable for use with cargo itself.

After making both of these changes, I can now run cargo-minor-mode commands in TRAMP buffers.

from cargo.el.

kwrooijen avatar kwrooijen commented on August 29, 2024

So I swapped the order of the arguments

You mean you changed it to? :

(let ((default-directory (or default-directory
                             (cargo-process--workspace-root))))

Doesn't that mean default-directory will never change, and therefore breaking the root workspace lookup?

from cargo.el.

bjc avatar bjc commented on August 29, 2024

That is the change I made. I figured it was not the right thing to do, but I wanted to test it to see if I could get cargo-minor-mode to work at all, and I wasn't sure what the rationale of the existing order was (besides it probably being important).

I'm not sure what you mean by "root workspace lookup". If you could explain why it's ordered the way it is in the current code, and how to test that its working properly, I'll try to fix it the right way. I just don't know enough about how things are supposed to work to attempt that right now.

from cargo.el.

kwrooijen avatar kwrooijen commented on August 29, 2024

It's ordered this way because we only want to change the default-directory if the root can be found using cargo-process--workspace-root. If no result is found just use default-directory (Note that the binding is the same name as the value). I think the cargo-process--workspace-root function needs to be changed to take TRAMP into consideration.

from cargo.el.

bjc avatar bjc commented on August 29, 2024

I'm looking into doing it this way, but it's trickier, because cargo-process--workspace-root parses the path directly from cargo output, so I'm going to have to add the current buffer's TRAMP prefix to it, but I can't see anything in TRAMP right now that will give me that prefix easily.

I could just take the current file name from the buffer and remove what's returned from (tramp-file-local-name buffer-file-name) but that seems pretty cllumsy, so I'll keep looking for a better way.

from cargo.el.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.