I want to run compile command from any buffer. So now my workaround is to 
change my build.sh to pipe the output to sed and prepend the project path name 
on the relative path name to make it an absolute path name. Since all my source 
code are under a single directory “src”, I was able to do this by something 
like:

   my-compile-command | sed 's|^src|'$prjdir'/src|g'

-Wenguang

> On Apr 10, 2020, at 11:52 PM, Michael Albinus <[email protected]> wrote:
> 
> Wenguang Wang <[email protected] <mailto:[email protected]>> writes:
> 
> Hi,
> 
>> My project has multiple directories and I want to invoke the build
>> command from any directory. My build system prints file path relative
>> to the project root directory. Therefore, when I build it on the
>> remote machine using emacs on the remote machine, I have to do this:
>> 
>> cd /abs/path/to/project_root ; ./build.sh
>> 
>> This makes emacs know that the file names in the compile errors starts
>> from which directory and I can use the “next-error” command to load
>> the file and jump to the right line.
>> 
>> However, when I run the compile command from tramp, this command fails
>> with: “No such directory found via CDPATH environment variable”.
>> 
>> Although I can start the command with: /bin/bash -c "cd
>> /abs/path/to/project_root ; ./build.sh”, it does not help because
>> emacs does not know the relative file path in the compile error has
>> changed to a different directory.
>> 
>> Is there a way to make this work under tramp?
> 
> You should work on a buffer which has the default-directory
> "/ssh:user@host:/abs/path/to/project_root". There you can call "M-x compile",
> and replace in the minibuffer the default command "make -k" by "./build.sh".
> 
> That's how I work all the time.
> 
>> Thanks!
>> -Wenguang
> 
> Best regards, Michael.

Reply via email to