From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Bruno Barbier Newsgroups: gmane.emacs.help Subject: Re: How to let tramp be aware the virtualenv? Date: Wed, 17 Jul 2019 23:02:07 +0200 Message-ID: <5d2f7e72.1c69fb81.f72ba.b0dd@mx.google.com> References: <5d2e15b2.1c69fb81.02bd.de51@mx.google.com> <87zhldur3a.fsf@gmx.de> <87pnm8vqry.fsf@gmx.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="153007"; mail-complaints-to="usenet@blaine.gmane.org" Cc: help-gnu-emacs@gnu.org To: Zhongwei Yao , Michael Albinus Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jul 17 22:01:02 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hnq6m-000daE-4w for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Jul 2019 22:01:00 +0200 Original-Received: from localhost ([::1]:60244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnq6l-0001TG-0m for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Jul 2019 16:00:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56844) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnq6g-0001Sy-Ob for help-gnu-emacs@gnu.org; Wed, 17 Jul 2019 16:00:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hnq6f-0004Vq-An for help-gnu-emacs@gnu.org; Wed, 17 Jul 2019 16:00:54 -0400 Original-Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:36612) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hnq6f-0004UZ-3w for help-gnu-emacs@gnu.org; Wed, 17 Jul 2019 16:00:53 -0400 Original-Received: by mail-wm1-x331.google.com with SMTP id g67so19228731wme.1 for ; Wed, 17 Jul 2019 13:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:from:to:cc:subject:in-reply-to:references:date :mime-version; bh=DKI/GexNRRM/u37zmpgsr3H9ZJewU/tK0gUeLiXLh3E=; b=D4BX9iyK0FmmQxsptjRoxB+CtTuhjO9xN/wGXLDVFnXs8eEdP0jt0n7zoWZUurVRfv vTxfHd/DruggU9Ph+LpEYQgJ2q2Gxfub+E5B6x2rkcKD5CIDftM4K/Kw8StO34tJnyRf /pKrbrFIrzOA3JGf3Am4fLTQ7b2vVgr1ZikantSLSYU1BLA68C9EYsmr1RK1y+U1I0k3 yAaiPKg795nCryyZyeW4Vucnw/W+toqtFHf2DCrQj9+PuTDBFJUcP7I6rBhL8ywezNE5 zn5RkR9bgCWdgXuvb0WBhJZkXuH2HJF2Uvlo+h9REZp4e87wppYchjMjNM4lxFlO9eh+ IOeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:in-reply-to :references:date:mime-version; bh=DKI/GexNRRM/u37zmpgsr3H9ZJewU/tK0gUeLiXLh3E=; b=htfdu/bZ3sH6fS78YFJos0fYDw7hRBwH3XQ41O9WYFM7pbjuzcLowB+amoFfsfVin/ j9lLR9G+5b7EnrBd1rBLL6eGqqM/L5mbaetMUODGPxeWfQa3eWuHsnkYmVxSFJHGNTZ5 gmVnoZAx5GrkqH3/ZXKD1PZGuX4pyFeS0qy1bruIK/td0ZKeBjmJ2r1AjSHAPaEkitJ3 2ndiDP3MZ/QurGtEC0tECiQkuDmni3gB1rwAE79HkgoG9Sm8MDGNSswEmmXQiYd20by/ vaim3OqGfk7JIWnTb2BTgRbF5mlasb9Z23kqYTR1PxqudeJbFzhi8rwxW5aYkLEiX3ar ogxQ== X-Gm-Message-State: APjAAAX6SUrPuIAob63EYX67cvTQd/GgGcEBIXvCAbA74wju98S5LuPO YDU25JPafzuA4vLBeUID4Xg= X-Google-Smtp-Source: APXvYqwJflP2U4oxiFIwyEsaVzpVQNyEHbppebevdoXQGsz30hq3g8Q+HhRBzBh6lky5Rb/HWBZ84A== X-Received: by 2002:a7b:cc04:: with SMTP id f4mr38984321wmh.125.1563393651174; Wed, 17 Jul 2019 13:00:51 -0700 (PDT) Original-Received: from tosh-laptop ([2a01:e0a:77:5500:198:efdf:4d36:80dc]) by smtp.gmail.com with ESMTPSA id 32sm19789068wrh.76.2019.07.17.13.00.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 13:00:50 -0700 (PDT) Original-Received: by tosh-laptop (sSMTP sendmail emulation); Wed, 17 Jul 2019 23:02:07 +0200 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::331 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:121195 Archived-At: Hi Zhongwei, Zhongwei Yao 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 > wrote: > >> Zhongwei Yao 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 >> > ) > > 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. >>