unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Bruno Barbier <brubar.cs@gmail.com>
To: Zhongwei Yao <ashi08104@gmail.com>
Cc: help-gnu-emacs@gnu.org, Michael Albinus <michael.albinus@gmx.de>
Subject: Re: How to let tramp be aware the virtualenv?
Date: Thu, 18 Jul 2019 19:45:53 +0200	[thread overview]
Message-ID: <5d30a1f2.1c69fb81.c4190.1ece@mx.google.com> (raw)
In-Reply-To: <CAJnfWeHjw8DkxtkJzO1M2UF2amYuuSYQo8r+kNhjcqt3nWMorA@mail.gmail.com>


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.
>> >>
>>



  reply	other threads:[~2019-07-18 17:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2019-07-19  1:04                   ` Zhongwei Yao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5d30a1f2.1c69fb81.c4190.1ece@mx.google.com \
    --to=brubar.cs@gmail.com \
    --cc=ashi08104@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=michael.albinus@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).