emacs-pe / docker-tramp.el

TRAMP integration for docker containers
340 stars 25 forks source link

TRAMP ignores PATH? #8

Closed Silex closed 8 years ago

Silex commented 8 years ago

Hello,

I'm aware that this is probably a TRAMP issue but I'm asking because maybe you have an idea.

When I do (async-shell-command "echo $PATH") over a docker-tramp connection, the PATH is not correct... you check can see this happen with the ruby:2.2 image, PATH should contain /usr/local/bundle/bin but it doesn't.

Maybe it's because this variable is set throught ENV in the Dockerfile? https://github.com/docker-library/ruby/blob/74ee8aec9c17ea2134db8a8ef199cf092c829576/2.2/Dockerfile

marsam commented 8 years ago

Hi, sorry for the late response. I've tested with docker 1.9.1 seems to work:

Dockerfile:

FROM ruby:2.2
ENV NAME "example"

# Local Variables:
# dockefile-image-name: "example"
# End:
$ docker run -it example env
PATH=/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=5ae2b0c343b5
TERM=xterm
RUBY_MAJOR=2.2
RUBY_VERSION=2.2.4
RUBY_DOWNLOAD_SHA256=b6eff568b48e0fda76e5a36333175df049b204e91217aa32a65153cc0cdcb761
RUBYGEMS_VERSION=2.5.1
GEM_HOME=/usr/local/bundle
BUNDLER_VERSION=1.11.2
BUNDLE_APP_CONFIG=/usr/local/bundle
NAME=example
HOME=/root
$
(let ((default-directory "/docker:0252746eea89:/"))
  (async-shell-command "echo $PATH"))
;; => /usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Maybe default-directory is not set correctly?

Silex commented 8 years ago

That's so weird... the other env variables looks fine but PATH seems to be force-set by TRAMP or smth.

I'll investiguate.... to reproduce more easily, simply open a file in the container then M-x shell RET echo $PATH RET

marsam commented 8 years ago

I think I misunderstood you; you can try adding the following to your init.el:

(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
Silex commented 8 years ago

No... anyway, I found how it happens, now I need to find why.

Basically, tramp-set-remote-path is called and it force-sets the path to the invalid value instead of letting it as is.

Silex commented 8 years ago

(add-to-list 'tramp-remote-path 'tramp-own-remote-path)

Damnit, you were right! This works!!!! Thanks 1642698246890427890 times :)

(why the hell isn't that the default)