tramp-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tramp-container doesn't follow `ENV PATH` in docker file


From: ParetoOptimalDev
Subject: Re: tramp-container doesn't follow `ENV PATH` in docker file
Date: Thu, 16 Mar 2023 10:55:27 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

Michael Albinus <michael.albinus@gmx.de> writes:

> Just for the records: I have seen also your first message. Since the
> times are busy, I have postponed to answer.

No problem!

> However, I agree we need to do something in this area.

Yes.

> Well, where does $PATH come from? Should it be your local $PATH on the
> machine you're calling docker?

It gets executed in the docker container, see: 

> Note, that your change wouldn't do anything. The $PATH on the docker
> instance is computed in the remote shell, based on tramp-remote-path. If
> you want to change something, it must be there.

> This mechanism is questionable in general. There is already the Emacs
> bug#61926, which asks for something else. This request is currently
> pending (due to other prioritzed work); when I'll work on this I will
> also take your request into account. If you like, you could also send a
> message to that bug number, requesting proper changes for docker. Just
> in case nobody forgets it.

Yes please. I have an updated elisp script to reproduce the
problem. Here is it's output:

```
$ emacs -Q --batch --load config.el
emacs-version: 30.0.50
tramp-version: 2.7.0-pre

using the docker haskell image
expected path is:
["PATH=/root/.cabal/bin:/root/.local/bin:/opt/ghc/9.4.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","LANG=C.UTF-8"]
Tramp: Sending command ‘exec docker exec -it nifty_davinci /bin/sh  -i’
Tramp: Found remote shell prompt on ‘nifty_davinci’
path is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
```

And the script:

```

(require 'tramp)

;; pre-require things that were making loading messages that clutter up stdout
(require 'em-alias)
(require 'em-banner)
(require 'em-basic)
(require 'em-cmpl)
(require 'em-extpipe)
(require 'em-glob)
(require 'em-hist)
(require 'em-ls)
(require 'em-pred)
(require 'em-prompt)
(require 'em-script)
(require 'em-term)
(require 'em-unix)

(setq edebug-print-length 500)
(setq tramp-verbose 7)

(setq existing-haskell-container-name "nifty_davinci")
(defun start-new-haskell-container ()
  """ returns container id"""
  (string-trim (shell-command-to-string "docker run -i --rm --detach 
haskell:slim@sha256:68280eb4fd3d4ee1b62cf40619fd6e956a741f693ef53e9dd4168d2c721880f5")))
(setq docker-container-id
      (or existing-haskell-container-name (start-new-haskell-container)))
(message (format "emacs-version: %s" emacs-version))
(message (format "tramp-version: %s" tramp-version))
(message "")
(message "using the docker haskell image")
(message "expected path is:")
(message (string-trim (shell-command-to-string (format "docker inspect 
--format='{{json .Config.Env}}' %s" docker-container-id))))

(let ((default-directory (concat "/docker:" docker-container-id ":"))
      (tramp-remote-path '(tramp-own-remote-path)))
  (tramp-cleanup-all-connections)
  (message (concat "path is: " (truncate-string-to-width (eshell-command-result 
"echo $PATH") 100))))

```

Thank you.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]