* How to let tramp be aware the virtualenv? @ 2019-07-16 10:30 Zhongwei Yao 2019-07-16 13:48 ` Michael Albinus 2019-07-16 19:22 ` Bruno Barbier 0 siblings, 2 replies; 14+ messages in thread From: Zhongwei Yao @ 2019-07-16 10:30 UTC (permalink / raw) To: help-gnu-emacs Hi, all, I try to use tramp on a remote project directory and run "M-x compile". The command requires to know which the python virtualenv is active. I try to let tramp be ware of which virtualenv is active by adding a line to the remote $HOME/.profile like (because it seems tramp will run the compilation command by the remote /bin/sh): source my/python/virtualenv/bin/activate. But tramp seems doesn't read that line at all. The virtualenv is not activated. So how can I make tramp aware of which virtualenv is enabled? Thanks! Zhongwei ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to let tramp be aware the virtualenv? 2019-07-16 10:30 How to let tramp be aware the virtualenv? Zhongwei Yao @ 2019-07-16 13:48 ` Michael Albinus 2019-07-16 19:22 ` Bruno Barbier 1 sibling, 0 replies; 14+ messages in thread From: Michael Albinus @ 2019-07-16 13:48 UTC (permalink / raw) To: Zhongwei Yao; +Cc: help-gnu-emacs Zhongwei Yao <ashi08104@gmail.com> writes: > Hi, all, Hi, > I try to let tramp be ware of which virtualenv is active by adding a line > to the remote $HOME/.profile like (because it seems tramp will run the > compilation command by the remote /bin/sh): > > source my/python/virtualenv/bin/activate. > > But tramp seems doesn't read that line at all. The virtualenv is not > activated. Tramp does not read ~/.profile. > Thanks! > Zhongwei Best regards, Michael. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to let tramp be aware the virtualenv? 2019-07-16 10:30 How to let tramp be aware the virtualenv? Zhongwei Yao 2019-07-16 13:48 ` Michael Albinus @ 2019-07-16 19:22 ` Bruno Barbier 2019-07-17 2:02 ` Zhongwei Yao 1 sibling, 1 reply; 14+ messages in thread From: Bruno Barbier @ 2019-07-16 19:22 UTC (permalink / raw) To: Zhongwei Yao, help-gnu-emacs Hi Zhongwei, Zhongwei Yao <ashi08104@gmail.com> writes: > Hi, all, > I try to use tramp on a remote project directory and run "M-x compile". The > command requires to know which the python virtualenv is active. > > I try to let tramp be ware of which virtualenv is active by adding a line > to the remote $HOME/.profile like (because it seems tramp will run the > compilation command by the remote /bin/sh): > > source my/python/virtualenv/bin/activate. > > But tramp seems doesn't read that line at all. The virtualenv is not > activated. > > So how can I make tramp aware of which virtualenv is enabled? > > Thanks! > Zhongwei Are you using SSH to connect ? If so, you might be able to configure SSH to do it. In your ~/.ssh/config (or where your ssh config is), add something like this: Host a-nice-and-very-short-name HostName 169.254.1.2 RequestTTy force RemoteCommand sh -c 'source my/python/virtualenv/bin/activate; bash -l' Then, using tramp, it should just work: /ssh:a-nice-and-very-short-name:/path/to/your-project Bruno ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to let tramp be aware the virtualenv? 2019-07-16 19:22 ` Bruno Barbier @ 2019-07-17 2:02 ` Zhongwei Yao 2019-07-17 6:12 ` Michael Albinus 0 siblings, 1 reply; 14+ messages in thread From: Zhongwei Yao @ 2019-07-17 2:02 UTC (permalink / raw) To: Bruno Barbier; +Cc: help-gnu-emacs Hi, Bruno, Thanks, but it still doesn't work. (I use ssh to connect to the remote Ubuntu server. And the /bin/sh is dash, so "source" does work. I replace it with "."). For example, when I run "echo $BASH_VERSION" in compilation command by tramp, it is empty. By using " RemoteCommand sh -c '. my/python/virtualenv/bin/activate; bash -l'", I think all command will run in bash, right? Am I missing something? Thanks, Zhongwei On Wed, Jul 17, 2019 at 2:21 AM Bruno Barbier <brubar.cs@gmail.com> wrote: > > Hi Zhongwei, > > > Zhongwei Yao <ashi08104@gmail.com> writes: > > > Hi, all, > > I try to use tramp on a remote project directory and run "M-x compile". > The > > command requires to know which the python virtualenv is active. > > > > I try to let tramp be ware of which virtualenv is active by adding a line > > to the remote $HOME/.profile like (because it seems tramp will run the > > compilation command by the remote /bin/sh): > > > > source my/python/virtualenv/bin/activate. > > > > But tramp seems doesn't read that line at all. The virtualenv is not > > activated. > > > > So how can I make tramp aware of which virtualenv is enabled? > > > > Thanks! > > Zhongwei > > Are you using SSH to connect ? > > If so, you might be able to configure SSH to do it. > > In your ~/.ssh/config (or where your ssh config is), add something like > this: > > Host a-nice-and-very-short-name > HostName 169.254.1.2 > RequestTTy force > RemoteCommand sh -c 'source my/python/virtualenv/bin/activate; bash > -l' > > > Then, using tramp, it should just work: > > /ssh:a-nice-and-very-short-name:/path/to/your-project > > > Bruno > > > > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to let tramp be aware the virtualenv? 2019-07-17 2:02 ` Zhongwei Yao @ 2019-07-17 6:12 ` Michael Albinus 2019-07-17 10:47 ` Zhongwei Yao 0 siblings, 1 reply; 14+ messages in thread From: Michael Albinus @ 2019-07-17 6:12 UTC (permalink / raw) To: Zhongwei Yao; +Cc: Bruno Barbier, help-gnu-emacs Zhongwei Yao <ashi08104@gmail.com> writes: > Hi, Bruno, Hi, > By using " RemoteCommand sh -c '. my/python/virtualenv/bin/activate; bash > -l'", I think all command will run in bash, right? Am I missing something? After login on the remote host, Tramp calls /bin/sh. That's why bash is not active. This could be overwritten by the connection property "remote-shell", see the Tramp manual. > Thanks, > Zhongwei Best regards, Michael. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to let tramp be aware the virtualenv? 2019-07-17 6:12 ` Michael Albinus @ 2019-07-17 10:47 ` Zhongwei Yao 2019-07-17 11:34 ` Michael Albinus 0 siblings, 1 reply; 14+ messages in thread From: Zhongwei Yao @ 2019-07-17 10:47 UTC (permalink / raw) To: Michael Albinus; +Cc: Bruno Barbier, help-gnu-emacs Hi, Michael, Thanks for your reply. But it does not work for me. I try to set the remote-shell to /bin/bash, and from tramp log, there is: xx8:15.682748 tramp-get-connection-property (7) # remote-shell /bin/bash But when I run the compilation command "echo ${BASH_VERSION}", it returns nothing. And I notice there is log line like: 38:15.720661 tramp-send-command (6) # cd /home/user/projects/foo/build/ && exec <<'6xxa3a8f7393fxxx' env PS1\=/ssh\:remote_machine\:/home/user/projects/foo/build/\ \#\$\ TERMCAP\= COLUMNS\=134 INSIDE_EMACS\=26.1\,compile /bin/sh ( echo $BASH_VERSION ) </dev/tty 6xxa3a8f7393fxxx It is still using /bin/sh. On Wed, Jul 17, 2019 at 2:12 PM Michael Albinus <michael.albinus@gmx.de> wrote: > Zhongwei Yao <ashi08104@gmail.com> writes: > > > Hi, Bruno, > > Hi, > > > By using " RemoteCommand sh -c '. my/python/virtualenv/bin/activate; bash > > -l'", I think all command will run in bash, right? Am I missing > something? > > After login on the remote host, Tramp calls /bin/sh. That's why bash is > not active. This could be overwritten by the connection property > "remote-shell", see the Tramp manual. > > > Thanks, > > Zhongwei > > Best regards, Michael. > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to let tramp be aware the virtualenv? 2019-07-17 10:47 ` Zhongwei Yao @ 2019-07-17 11:34 ` Michael Albinus 2019-07-17 13:40 ` Zhongwei Yao 0 siblings, 1 reply; 14+ messages in thread From: Michael Albinus @ 2019-07-17 11:34 UTC (permalink / raw) To: Zhongwei Yao; +Cc: Bruno Barbier, help-gnu-emacs Zhongwei Yao <ashi08104@gmail.com> writes: > Hi, Michael, Hi, > I try to set the remote-shell to /bin/bash, and from tramp log, there > is: > xx8:15.682748 tramp-get-connection-property (7) # remote-shell > /bin/bash Good. > And I notice there is log line like: > 38:15.720661 tramp-send-command (6) # cd > /home/user/projects/foo/build/ && exec <<'6xxa3a8f7393fxxx' env > PS1\=/ssh\:remote_machine\:/home/user/projects/foo/build/\ \#\$\ > TERMCAP\= COLUMNS\=134 INSIDE_EMACS\=26.1\,compile /bin/sh > ( > echo $BASH_VERSION > ) </dev/tty > 6xxa3a8f7393fxxx > > It is still using /bin/sh. This isn't any longer Tramp. *This* hard coded /bin/sh comes from the compile command. Apparently, you're using Emacs 26. In Emacs 27, compile can be configured to use connection local variables, which would overwrite this. Do you have a chance to run the development version of Emacs? Best regards, Michael. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to let tramp be aware the virtualenv? 2019-07-17 11:34 ` Michael Albinus @ 2019-07-17 13:40 ` Zhongwei Yao 2019-07-17 14:05 ` Michael Albinus ` (2 more replies) 0 siblings, 3 replies; 14+ messages in thread From: Zhongwei Yao @ 2019-07-17 13:40 UTC (permalink / raw) To: Michael Albinus; +Cc: Bruno Barbier, help-gnu-emacs Thanks. I try emacs27 and using connection-local-set-profiles. And I can run into bash in compile command. But running into bash is not my objective. (I try to add source my/python/virtualenv/bin/activate to bashrc, and it doesn't work. The bash run in non-interative shell and seems doesn't read my bashrc). I want to make the compilation under tramp know which python virtual env is activate. Currently, I have a workaround by using the following compile command: . /path/to/the/virtual/env/activate && python --version But it is in-convenient that each compile command needs a ". /xxx/activate" prefix. I don't know whether there is a way to make the compile command aware of which virtualenv is activate without using such prefix. On Wed, Jul 17, 2019 at 7:34 PM Michael Albinus <michael.albinus@gmx.de> wrote: > Zhongwei Yao <ashi08104@gmail.com> writes: > > > Hi, Michael, > > Hi, > > > I try to set the remote-shell to /bin/bash, and from tramp log, there > > is: > > xx8:15.682748 tramp-get-connection-property (7) # remote-shell > > /bin/bash > > Good. > > > And I notice there is log line like: > > 38:15.720661 tramp-send-command (6) # cd > > /home/user/projects/foo/build/ && exec <<'6xxa3a8f7393fxxx' env > > PS1\=/ssh\:remote_machine\:/home/user/projects/foo/build/\ \#\$\ > > TERMCAP\= COLUMNS\=134 INSIDE_EMACS\=26.1\,compile /bin/sh > > ( > > echo $BASH_VERSION > > ) </dev/tty > > 6xxa3a8f7393fxxx > > > > It is still using /bin/sh. > > This isn't any longer Tramp. *This* hard coded /bin/sh comes from the > compile command. > > Apparently, you're using Emacs 26. In Emacs 27, compile can be > configured to use connection local variables, which would overwrite > this. > > Do you have a chance to run the development version of Emacs? > > Best regards, Michael. > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to let tramp be aware the virtualenv? 2019-07-17 13:40 ` Zhongwei Yao @ 2019-07-17 14:05 ` Michael Albinus 2019-07-17 16:02 ` Yuri Khan 2019-07-17 21:02 ` Bruno Barbier 2 siblings, 0 replies; 14+ messages in thread From: Michael Albinus @ 2019-07-17 14:05 UTC (permalink / raw) To: Zhongwei Yao; +Cc: Bruno Barbier, help-gnu-emacs Zhongwei Yao <ashi08104@gmail.com> writes: Hi, > Thanks. I try emacs27 and using connection-local-set-profiles. And I > can run into bash in compile command. But running into bash is not my > objective. (I try to add source my/python/virtualenv/bin/activate to > bashrc, and it doesn't work. The bash run in non-interative shell and > seems doesn't read my bashrc). Well, if you use connection-local variables, you could say to bash what to do. Likely, you have defined something like --8<---------------cut here---------------start------------->8--- (connection-local-set-profile-variables 'remote-bash '((explicit-shell-file-name . "/bin/bash") (explicit-bash-args . ("-i")))) --8<---------------cut here---------------end--------------->8--- (taken from the manual). But if you add the "-l" arg, bash is a login shell, and reads .bashrc. Like this (untested): --8<---------------cut here---------------start------------->8--- (connection-local-set-profile-variables 'remote-bash '((explicit-shell-file-name . "/bin/bash") (explicit-bash-args . ("-i" "-l")))) --8<---------------cut here---------------end--------------->8--- Best regards, Michael. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to let tramp be aware the virtualenv? 2019-07-17 13:40 ` Zhongwei Yao 2019-07-17 14:05 ` Michael Albinus @ 2019-07-17 16:02 ` Yuri Khan 2019-07-17 21:02 ` Bruno Barbier 2 siblings, 0 replies; 14+ messages in thread From: Yuri Khan @ 2019-07-17 16:02 UTC (permalink / raw) To: Zhongwei Yao; +Cc: Bruno Barbier, help-gnu-emacs, Michael Albinus On Wed, Jul 17, 2019 at 8:41 PM Zhongwei Yao <ashi08104@gmail.com> wrote: > I want to make the compilation under tramp know which python virtual env is > activate. Currently, I have a workaround by using the following compile > command: > . /path/to/the/virtual/env/activate && python --version In many cases, you do not need to activate the virtualenv specifically. You can just execute whatever script you want using the copy of the python executable installed in that environment’s bin subdirectory: /path/to/the/virtual/env/bin/python --version Disclaimer: I have only verified this to work in Python 3.5 and above, and never tried that over Tramp. Also, if your Python program calls an external subprocess that in turn calls another Python program without specifying the interpreter path, it will get executed with the default interpreter, which might not be what you want. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to let tramp be aware the virtualenv? 2019-07-17 13:40 ` Zhongwei Yao 2019-07-17 14:05 ` Michael Albinus 2019-07-17 16:02 ` Yuri Khan @ 2019-07-17 21:02 ` Bruno Barbier 2019-07-18 13:21 ` Zhongwei Yao 2 siblings, 1 reply; 14+ messages in thread From: Bruno Barbier @ 2019-07-17 21:02 UTC (permalink / raw) To: Zhongwei Yao, Michael Albinus; +Cc: help-gnu-emacs Hi Zhongwei, Zhongwei Yao <ashi08104@gmail.com> writes: > Thanks. I try emacs27 and using connection-local-set-profiles. And I can > run into bash in compile command. But running into bash is not my > objective. (I try to add source my/python/virtualenv/bin/activate to > bashrc, and it doesn't work. The bash run in non-interative shell and seems > doesn't read my bashrc). > > I want to make the compilation under tramp know which python virtual env is > activate. Currently, I have a workaround by using the following compile > command: > . /path/to/the/virtual/env/activate && python --version > > But it is in-convenient that each compile command needs a ". /xxx/activate" > prefix. I don't know whether there is a way to make the compile command > aware of which virtualenv is activate without using such prefix. > I'm using: emacs 26.1 tramp 2.3.3.26.1 It's just working for me; so, I don't understand what I'm missing here (sorry about the bash 'source' thing). The only thing, that I did, is to configure SSH so that it gives a proper shell to tramp. Host nice-tramp HostName xxx.xxx.xxx.xxx RequestTTy force RemoteCommand dash -c '. path/to/my-init.sh; dash -l' As said by Michael, in another email in this thread, your problem is probably not with tramp. What do you get when connecting directly using SSH in a console ? (you need to get a proper shell, with prompt/input/output/echo). If I type: ssh nice-tramp I'm connected, getting a shell with a prompt (the thing that tramp needs to work), and, that shell works like any console shell: input, echo, prompt. If I enter, in this shell the command: type $0 I get: dash is /bin/dash (yes, I installed 'dash', just to double-check what I could be missing) Once this is working, in Emacs, I do: /ssh:nice-tramp:/whatever/path/ and Emacs/Tramp shows me the directory In this directory, if I do 'M-x shell', I get a remote shell, on this directory. My init script contains: export MY_VIRTUAL_ENV="Yes" And, after 'M-x shell', entering: 'export | grep MY', I get: declare -x MY_VIRTUAL_ENV="Yes" (my 'sh' is 'bash', not using Ubuntu, that's tramp shell, and it's fine for me) If I enter, M-x compile "echo $MY_VIRTUAL_ENV", I'm getting a compilation buffer with: echo $MY_VIRTUAL_ENV Yes So only configuring SSH works for me. I'm not sure I understand what's not working for you. Once Tramp gets a proper shell, it should just work (it can be sh, bash, dash, etc.). Just provide a proper interactive shell, and let tramp take it from there. Any idea what test I can do to understand what I'm missing ? Bruno > On Wed, Jul 17, 2019 at 7:34 PM Michael Albinus <michael.albinus@gmx.de> > wrote: > >> Zhongwei Yao <ashi08104@gmail.com> writes: >> >> > Hi, Michael, >> >> Hi, >> >> > I try to set the remote-shell to /bin/bash, and from tramp log, there >> > is: >> > xx8:15.682748 tramp-get-connection-property (7) # remote-shell >> > /bin/bash >> >> Good. >> >> > And I notice there is log line like: >> > 38:15.720661 tramp-send-command (6) # cd >> > /home/user/projects/foo/build/ && exec <<'6xxa3a8f7393fxxx' env >> > PS1\=/ssh\:remote_machine\:/home/user/projects/foo/build/\ \#\$\ >> > TERMCAP\= COLUMNS\=134 INSIDE_EMACS\=26.1\,compile /bin/sh >> > ( >> > echo $BASH_VERSION >> > ) </dev/tty >> > 6xxa3a8f7393fxxx >> > >> > It is still using /bin/sh. >> >> This isn't any longer Tramp. *This* hard coded /bin/sh comes from the >> compile command. >> >> Apparently, you're using Emacs 26. In Emacs 27, compile can be >> configured to use connection local variables, which would overwrite >> this. >> >> Do you have a chance to run the development version of Emacs? >> >> Best regards, Michael. >> ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to let tramp be aware the virtualenv? 2019-07-17 21:02 ` Bruno Barbier @ 2019-07-18 13:21 ` Zhongwei Yao 2019-07-18 17:45 ` Bruno Barbier 0 siblings, 1 reply; 14+ messages in thread From: Zhongwei Yao @ 2019-07-18 13:21 UTC (permalink / raw) To: Bruno Barbier; +Cc: help-gnu-emacs, Michael Albinus Hi, Bruno, I tried your suggestion again. And changed it to: RequestTTy force RemoteCommand bash -c 'export PATH=mypath:$PATH; export FOO=bar; bash -l' And if use "env" as my compile command, it prints: FOO=bar PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin But if I ssh to that machine directly in the terminal(out side of emacs) and type "env", I got: FOO=bar PATH=mypath:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin Emacs reset the PATH at somewhere and it leads to can't find the python in the virtual-env! And my environment is Emacs 26.1 on mac and tramp-version 2.3.3.26.1. I test this by emacs -Q and also remove remote machine's .bashrc. I also tried Michael's 'explicit-bash-args . ("-i" "-l")', and run "M-x compile" and get a similar result: I can set other ENV variable (like FOO) but can not set the PATH variable. I have not found where emacs sets (reset) the PATH yet. On Thu, Jul 18, 2019 at 4:00 AM Bruno Barbier <brubar.cs@gmail.com> wrote: > > Hi Zhongwei, > > Zhongwei Yao <ashi08104@gmail.com> writes: > > > Thanks. I try emacs27 and using connection-local-set-profiles. And I can > > run into bash in compile command. But running into bash is not my > > objective. (I try to add source my/python/virtualenv/bin/activate to > > bashrc, and it doesn't work. The bash run in non-interative shell and > seems > > doesn't read my bashrc). > > > > I want to make the compilation under tramp know which python virtual env > is > > activate. Currently, I have a workaround by using the following compile > > command: > > . /path/to/the/virtual/env/activate && python --version > > > > But it is in-convenient that each compile command needs a ". > /xxx/activate" > > prefix. I don't know whether there is a way to make the compile command > > aware of which virtualenv is activate without using such prefix. > > > I'm using: > emacs 26.1 > tramp 2.3.3.26.1 > > It's just working for me; so, I don't understand what I'm missing here > (sorry about the bash 'source' thing). > > The only thing, that I did, is to configure SSH so that it gives a > proper shell to tramp. > > Host nice-tramp > HostName xxx.xxx.xxx.xxx > RequestTTy force > RemoteCommand dash -c '. path/to/my-init.sh; dash -l' > > > As said by Michael, in another email in this thread, your problem is > probably not with tramp. > > What do you get when connecting directly using SSH in a console ? (you > need to get a proper shell, with prompt/input/output/echo). > > If I type: > ssh nice-tramp > > I'm connected, getting a shell with a prompt (the thing that tramp needs > to work), and, that shell works like any console shell: input, echo, > prompt. > > If I enter, in this shell the command: > type $0 > > I get: > dash is /bin/dash > > (yes, I installed 'dash', just to double-check what I could be missing) > > > Once this is working, in Emacs, I do: > > /ssh:nice-tramp:/whatever/path/ > > and Emacs/Tramp shows me the directory > > In this directory, if I do 'M-x shell', I get a remote shell, on this > directory. > > My init script contains: > export MY_VIRTUAL_ENV="Yes" > > And, after 'M-x shell', entering: 'export | grep MY', I get: > declare -x MY_VIRTUAL_ENV="Yes" > > (my 'sh' is 'bash', not using Ubuntu, that's tramp shell, and it's > fine for me) > > > If I enter, M-x compile "echo $MY_VIRTUAL_ENV", I'm getting a compilation > buffer with: > > echo $MY_VIRTUAL_ENV > Yes > > > So only configuring SSH works for me. I'm not sure I understand what's > not working for you. Once Tramp gets a proper shell, it should just work > (it can be sh, bash, dash, etc.). Just provide a proper interactive > shell, and let tramp take it from there. > > Any idea what test I can do to understand what I'm missing ? > > > > Bruno > > > > > > > On Wed, Jul 17, 2019 at 7:34 PM Michael Albinus <michael.albinus@gmx.de> > > wrote: > > > >> Zhongwei Yao <ashi08104@gmail.com> writes: > >> > >> > Hi, Michael, > >> > >> Hi, > >> > >> > I try to set the remote-shell to /bin/bash, and from tramp log, there > >> > is: > >> > xx8:15.682748 tramp-get-connection-property (7) # remote-shell > >> > /bin/bash > >> > >> Good. > >> > >> > And I notice there is log line like: > >> > 38:15.720661 tramp-send-command (6) # cd > >> > /home/user/projects/foo/build/ && exec <<'6xxa3a8f7393fxxx' env > >> > PS1\=/ssh\:remote_machine\:/home/user/projects/foo/build/\ \#\$\ > >> > TERMCAP\= COLUMNS\=134 INSIDE_EMACS\=26.1\,compile /bin/sh > >> > ( > >> > echo $BASH_VERSION > >> > ) </dev/tty > >> > 6xxa3a8f7393fxxx > >> > > >> > It is still using /bin/sh. > >> > >> This isn't any longer Tramp. *This* hard coded /bin/sh comes from the > >> compile command. > >> > >> Apparently, you're using Emacs 26. In Emacs 27, compile can be > >> configured to use connection local variables, which would overwrite > >> this. > >> > >> Do you have a chance to run the development version of Emacs? > >> > >> Best regards, Michael. > >> > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to let tramp be aware the virtualenv? 2019-07-18 13:21 ` Zhongwei Yao @ 2019-07-18 17:45 ` Bruno Barbier 2019-07-19 1:04 ` Zhongwei Yao 0 siblings, 1 reply; 14+ messages in thread From: Bruno Barbier @ 2019-07-18 17:45 UTC (permalink / raw) To: Zhongwei Yao; +Cc: help-gnu-emacs, Michael Albinus Hi Zhongwei, Zhongwei Yao <ashi08104@gmail.com> writes: > ... > Emacs reset the PATH at somewhere and it leads to can't find the python in > the virtual-env! > > ... > > I have not found where emacs sets (reset) the PATH yet. > Indeed, same here. Look at: (customize-variable 'tramp-remote-path) If you add the symbol tramp-own-remote-path to the list, tramp will also add your existing remote PATH, when redefining the PATH. It's working for me. Try with a real existing path, as tramp might remove non-existing useless paths. Bruno > > On Thu, Jul 18, 2019 at 4:00 AM Bruno Barbier <brubar.cs@gmail.com> wrote: > >> >> Hi Zhongwei, >> >> Zhongwei Yao <ashi08104@gmail.com> writes: >> >> > Thanks. I try emacs27 and using connection-local-set-profiles. And I can >> > run into bash in compile command. But running into bash is not my >> > objective. (I try to add source my/python/virtualenv/bin/activate to >> > bashrc, and it doesn't work. The bash run in non-interative shell and >> seems >> > doesn't read my bashrc). >> > >> > I want to make the compilation under tramp know which python virtual env >> is >> > activate. Currently, I have a workaround by using the following compile >> > command: >> > . /path/to/the/virtual/env/activate && python --version >> > >> > But it is in-convenient that each compile command needs a ". >> /xxx/activate" >> > prefix. I don't know whether there is a way to make the compile command >> > aware of which virtualenv is activate without using such prefix. >> > >> I'm using: >> emacs 26.1 >> tramp 2.3.3.26.1 >> >> It's just working for me; so, I don't understand what I'm missing here >> (sorry about the bash 'source' thing). >> >> The only thing, that I did, is to configure SSH so that it gives a >> proper shell to tramp. >> >> Host nice-tramp >> HostName xxx.xxx.xxx.xxx >> RequestTTy force >> RemoteCommand dash -c '. path/to/my-init.sh; dash -l' >> >> >> As said by Michael, in another email in this thread, your problem is >> probably not with tramp. >> >> What do you get when connecting directly using SSH in a console ? (you >> need to get a proper shell, with prompt/input/output/echo). >> >> If I type: >> ssh nice-tramp >> >> I'm connected, getting a shell with a prompt (the thing that tramp needs >> to work), and, that shell works like any console shell: input, echo, >> prompt. >> >> If I enter, in this shell the command: >> type $0 >> >> I get: >> dash is /bin/dash >> >> (yes, I installed 'dash', just to double-check what I could be missing) >> >> >> Once this is working, in Emacs, I do: >> >> /ssh:nice-tramp:/whatever/path/ >> >> and Emacs/Tramp shows me the directory >> >> In this directory, if I do 'M-x shell', I get a remote shell, on this >> directory. >> >> My init script contains: >> export MY_VIRTUAL_ENV="Yes" >> >> And, after 'M-x shell', entering: 'export | grep MY', I get: >> declare -x MY_VIRTUAL_ENV="Yes" >> >> (my 'sh' is 'bash', not using Ubuntu, that's tramp shell, and it's >> fine for me) >> >> >> If I enter, M-x compile "echo $MY_VIRTUAL_ENV", I'm getting a compilation >> buffer with: >> >> echo $MY_VIRTUAL_ENV >> Yes >> >> >> So only configuring SSH works for me. I'm not sure I understand what's >> not working for you. Once Tramp gets a proper shell, it should just work >> (it can be sh, bash, dash, etc.). Just provide a proper interactive >> shell, and let tramp take it from there. >> >> Any idea what test I can do to understand what I'm missing ? >> >> >> >> Bruno >> >> >> >> >> >> > On Wed, Jul 17, 2019 at 7:34 PM Michael Albinus <michael.albinus@gmx.de> >> > wrote: >> > >> >> Zhongwei Yao <ashi08104@gmail.com> writes: >> >> >> >> > Hi, Michael, >> >> >> >> Hi, >> >> >> >> > I try to set the remote-shell to /bin/bash, and from tramp log, there >> >> > is: >> >> > xx8:15.682748 tramp-get-connection-property (7) # remote-shell >> >> > /bin/bash >> >> >> >> Good. >> >> >> >> > And I notice there is log line like: >> >> > 38:15.720661 tramp-send-command (6) # cd >> >> > /home/user/projects/foo/build/ && exec <<'6xxa3a8f7393fxxx' env >> >> > PS1\=/ssh\:remote_machine\:/home/user/projects/foo/build/\ \#\$\ >> >> > TERMCAP\= COLUMNS\=134 INSIDE_EMACS\=26.1\,compile /bin/sh >> >> > ( >> >> > echo $BASH_VERSION >> >> > ) </dev/tty >> >> > 6xxa3a8f7393fxxx >> >> > >> >> > It is still using /bin/sh. >> >> >> >> This isn't any longer Tramp. *This* hard coded /bin/sh comes from the >> >> compile command. >> >> >> >> Apparently, you're using Emacs 26. In Emacs 27, compile can be >> >> configured to use connection local variables, which would overwrite >> >> this. >> >> >> >> Do you have a chance to run the development version of Emacs? >> >> >> >> Best regards, Michael. >> >> >> ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to let tramp be aware the virtualenv? 2019-07-18 17:45 ` Bruno Barbier @ 2019-07-19 1:04 ` Zhongwei Yao 0 siblings, 0 replies; 14+ messages in thread From: Zhongwei Yao @ 2019-07-19 1:04 UTC (permalink / raw) To: Bruno Barbier; +Cc: help-gnu-emacs, Michael Albinus Hi, Bruno, Customizing the tramp-remote-path works for me. Thanks! On Fri, Jul 19, 2019 at 12:44 AM Bruno Barbier <brubar.cs@gmail.com> wrote: > > Hi Zhongwei, > > Zhongwei Yao <ashi08104@gmail.com> writes: > > > ... > > > Emacs reset the PATH at somewhere and it leads to can't find the python > in > > the virtual-env! > > > > ... > > > > I have not found where emacs sets (reset) the PATH yet. > > > Indeed, same here. > > Look at: > > (customize-variable 'tramp-remote-path) > > If you add the symbol tramp-own-remote-path to the list, tramp will also > add your existing remote PATH, when redefining the PATH. It's working > for me. Try with a real existing path, as tramp might remove > non-existing useless paths. > > Bruno > > > > > > > On Thu, Jul 18, 2019 at 4:00 AM Bruno Barbier <brubar.cs@gmail.com> > wrote: > > > >> > >> Hi Zhongwei, > >> > >> Zhongwei Yao <ashi08104@gmail.com> writes: > >> > >> > Thanks. I try emacs27 and using connection-local-set-profiles. And I > can > >> > run into bash in compile command. But running into bash is not my > >> > objective. (I try to add source my/python/virtualenv/bin/activate to > >> > bashrc, and it doesn't work. The bash run in non-interative shell and > >> seems > >> > doesn't read my bashrc). > >> > > >> > I want to make the compilation under tramp know which python virtual > env > >> is > >> > activate. Currently, I have a workaround by using the following > compile > >> > command: > >> > . /path/to/the/virtual/env/activate && python --version > >> > > >> > But it is in-convenient that each compile command needs a ". > >> /xxx/activate" > >> > prefix. I don't know whether there is a way to make the compile > command > >> > aware of which virtualenv is activate without using such prefix. > >> > > >> I'm using: > >> emacs 26.1 > >> tramp 2.3.3.26.1 > >> > >> It's just working for me; so, I don't understand what I'm missing here > >> (sorry about the bash 'source' thing). > >> > >> The only thing, that I did, is to configure SSH so that it gives a > >> proper shell to tramp. > >> > >> Host nice-tramp > >> HostName xxx.xxx.xxx.xxx > >> RequestTTy force > >> RemoteCommand dash -c '. path/to/my-init.sh; dash -l' > >> > >> > >> As said by Michael, in another email in this thread, your problem is > >> probably not with tramp. > >> > >> What do you get when connecting directly using SSH in a console ? (you > >> need to get a proper shell, with prompt/input/output/echo). > >> > >> If I type: > >> ssh nice-tramp > >> > >> I'm connected, getting a shell with a prompt (the thing that tramp needs > >> to work), and, that shell works like any console shell: input, echo, > >> prompt. > >> > >> If I enter, in this shell the command: > >> type $0 > >> > >> I get: > >> dash is /bin/dash > >> > >> (yes, I installed 'dash', just to double-check what I could be missing) > >> > >> > >> Once this is working, in Emacs, I do: > >> > >> /ssh:nice-tramp:/whatever/path/ > >> > >> and Emacs/Tramp shows me the directory > >> > >> In this directory, if I do 'M-x shell', I get a remote shell, on this > >> directory. > >> > >> My init script contains: > >> export MY_VIRTUAL_ENV="Yes" > >> > >> And, after 'M-x shell', entering: 'export | grep MY', I get: > >> declare -x MY_VIRTUAL_ENV="Yes" > >> > >> (my 'sh' is 'bash', not using Ubuntu, that's tramp shell, and it's > >> fine for me) > >> > >> > >> If I enter, M-x compile "echo $MY_VIRTUAL_ENV", I'm getting a > compilation > >> buffer with: > >> > >> echo $MY_VIRTUAL_ENV > >> Yes > >> > >> > >> So only configuring SSH works for me. I'm not sure I understand what's > >> not working for you. Once Tramp gets a proper shell, it should just work > >> (it can be sh, bash, dash, etc.). Just provide a proper interactive > >> shell, and let tramp take it from there. > >> > >> Any idea what test I can do to understand what I'm missing ? > >> > >> > >> > >> Bruno > >> > >> > >> > >> > >> > >> > On Wed, Jul 17, 2019 at 7:34 PM Michael Albinus < > michael.albinus@gmx.de> > >> > wrote: > >> > > >> >> Zhongwei Yao <ashi08104@gmail.com> writes: > >> >> > >> >> > Hi, Michael, > >> >> > >> >> Hi, > >> >> > >> >> > I try to set the remote-shell to /bin/bash, and from tramp log, > there > >> >> > is: > >> >> > xx8:15.682748 tramp-get-connection-property (7) # remote-shell > >> >> > /bin/bash > >> >> > >> >> Good. > >> >> > >> >> > And I notice there is log line like: > >> >> > 38:15.720661 tramp-send-command (6) # cd > >> >> > /home/user/projects/foo/build/ && exec <<'6xxa3a8f7393fxxx' env > >> >> > PS1\=/ssh\:remote_machine\:/home/user/projects/foo/build/\ \#\$\ > >> >> > TERMCAP\= COLUMNS\=134 INSIDE_EMACS\=26.1\,compile /bin/sh > >> >> > ( > >> >> > echo $BASH_VERSION > >> >> > ) </dev/tty > >> >> > 6xxa3a8f7393fxxx > >> >> > > >> >> > It is still using /bin/sh. > >> >> > >> >> This isn't any longer Tramp. *This* hard coded /bin/sh comes from the > >> >> compile command. > >> >> > >> >> Apparently, you're using Emacs 26. In Emacs 27, compile can be > >> >> configured to use connection local variables, which would overwrite > >> >> this. > >> >> > >> >> Do you have a chance to run the development version of Emacs? > >> >> > >> >> Best regards, Michael. > >> >> > >> > ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2019-07-19 1:04 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-07-16 10:30 How to let tramp be aware the virtualenv? Zhongwei Yao 2019-07-16 13:48 ` Michael Albinus 2019-07-16 19:22 ` Bruno Barbier 2019-07-17 2:02 ` Zhongwei Yao 2019-07-17 6:12 ` Michael Albinus 2019-07-17 10:47 ` Zhongwei Yao 2019-07-17 11:34 ` Michael Albinus 2019-07-17 13:40 ` Zhongwei Yao 2019-07-17 14:05 ` Michael Albinus 2019-07-17 16:02 ` Yuri Khan 2019-07-17 21:02 ` Bruno Barbier 2019-07-18 13:21 ` Zhongwei Yao 2019-07-18 17:45 ` Bruno Barbier 2019-07-19 1:04 ` Zhongwei Yao
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).