purcell / exec-path-from-shell

Make Emacs use the $PATH set up by the user's shell
Other
1.41k stars 81 forks source link

Broken with xonsh #48

Closed autrilla closed 7 years ago

autrilla commented 7 years ago

When running exec-path-from-shell from macOS Sierra and xonsh as my default shell, I get the following error:

Warning (initialization): An error occurred while loading ‘/Users/autrilla/.emacs.d/init.el’:

error: Non-zero exit code from shell /usr/local/bin/xonsh invoked with args ("-l" "-i" "-c" "/usr/bin/printf '__RESULT\\000%s\\000%s' \"${PATH-ed5bedb9d1d7d2085e34acc2d4a2e61a}\" \"${MANPATH-ed5bedb9d1d7d2085e34acc2d4a2e61a}\"").  Output was:
"Traceback (most recent call last):
  File \"/usr/local/bin/xonsh\", line 3, in <module>
    main()
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 17488, in main
    run_code_with_cache(args.command.lstrip(), shell.execer, mode='single')
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 2086, in run_code_with_cache
    run_compiled_code(ccode, glb, loc, mode)
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 1961, in run_compiled_code
    func(code, glb, loc)
  File \"ce9d521e89dbcd8a2350b8da8bc47901\", line 1, in <module>
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 16462, in subproc_captured_hiddenobject
    return run_subproc(cmds, captured='hiddenobject')
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 16325, in run_subproc
    **subproc_kwargs)
  File \"/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py\", line 947, in __init__
    restore_signals, start_new_session)
  File \"/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py\", line 1490, in _execute_child
    restore_signals, start_new_session, preexec_fn)
ValueError: embedded null byte
"

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.
~ $ (getenv "SHELL")
/usr/local/bin/xonsh
purcell commented 7 years ago

Please can you try modifying the exec-path-from-shell--standard-shell-p function so that it returns non-nil for xonsh, and tell me if that works for you?

autrilla commented 7 years ago

Unfortunately it does not. I don't know anything about emacs's escape sequences, so I'm not sure what exactly is being passed to xonsh.

Warning (initialization): An error occurred while loading ‘/Users/autrilla/.emacs.d/init.el’:

error: Non-zero exit code from shell /usr/local/bin/xonsh invoked with args ("-l" "-i" "-c" "sh -c /usr/bin/printf\\ \\'__RESULT\\\\000\\%s\\\\000\\%s\\'\\ \\\"\\$\\{PATH-cf27d4b8e449cf22670ae455a8cb7c00\\}\\\"\\ \\\"\\$\\{MANPATH-cf27d4b8e449cf22670ae455a8cb7c00\\}\\\"").  Output was:
"Traceback (most recent call last):
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 16978, in _parse_ctx_free
    debug_level=(self.debug_level > 1))
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/parsers/base.py\", line 324, in parse
    tree = self.parser.parse(input=s, lexer=self.lexer, debug=debug_level)
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/ply/yacc.py\", line 331, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/ply/yacc.py\", line 1181, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/ply/yacc.py\", line 193, in call_errorfunc
    r = errorfunc(token)
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/parsers/base.py\", line 2582, in p_error
    column=p.lexpos))
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/parsers/base.py\", line 450, in _parse_error
    raise err
SyntaxError: e3694a1112a05d42f84eb4b27db5f897:1:60: ('code: {',)
![sh -c /usr/bin/printf\\ \\'__RESULT\\\\000\\%s\\\\000\\%s\\'\\ \\\"\\$\\{PATH-cf27d4b8e449cf22670ae455a8cb7c00\\}\\\"\\ \\\"\\$\\{MANPATH-cf27d4b8e449cf22670ae455a8cb7c00\\}\\\"]
                                                            ^

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File \"/usr/local/bin/xonsh\", line 3, in <module>
    main()
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 17488, in main
    run_code_with_cache(args.command.lstrip(), shell.execer, mode='single')
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 2084, in run_code_with_cache
    ccode = compile_code(filename, code, execer, glb, loc, mode)
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 2000, in compile_code
    ccode = execer.compile(code, glbs=glb, locs=loc, mode=mode)
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 16917, in compile
    transform=transform)
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 16887, in parse
    tree, input = self._parse_ctx_free(input, mode=mode, filename=filename)
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 17036, in _parse_ctx_free
    raise original_error
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 16978, in _parse_ctx_free
    debug_level=(self.debug_level > 1))
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/parsers/base.py\", line 324, in parse
    tree = self.parser.parse(input=s, lexer=self.lexer, debug=debug_level)
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/ply/yacc.py\", line 331, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/ply/yacc.py\", line 1181, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/ply/yacc.py\", line 193, in call_errorfunc
    r = errorfunc(token)
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/parsers/base.py\", line 2577, in p_error
    column=p.lexpos))
  File \"/usr/local/Cellar/xonsh/0.4.6/libexec/lib/python3.5/site-packages/xonsh/parsers/base.py\", line 450, in _parse_error
    raise err
SyntaxError: e3694a1112a05d42f84eb4b27db5f897:1:21: \\
sh -c /usr/bin/printf\\ \\'__RESULT\\\\000\\%s\\\\000\\%s\\'\\ \\\"\\$\\{PATH-cf27d4b8e449cf22670ae455a8cb7c00\\}\\\"\\ \\\"\\$\\{MANPATH-cf27d4b8e449cf22670ae455a8cb7c00\\}\\\"
                     ^
"
purcell commented 7 years ago

Hmmm... The approach taken by exec-path-from-shell works for other non-POSIX shells such as fish, so my feeling is that this will likely require an upstream fix in xonsh's parser. I won't be investigating this problem further myself, sorry, but if it turns out there's a very simple workaround we can add to exec-path-from-shell, then I'd welcome a pull request.