SublimeREPL icon indicating copy to clipboard operation
SublimeREPL copied to clipboard

getenv() fails to get environment in Sublime Text 2 (OS X)

Open sorig opened this issue 12 years ago • 21 comments

After installing SublimeREPL in Sublime Text 2 and opening a REPL I get this error message (and a pop-up alert).

Traceback (most recent call last):
  File "./repls/subprocess_repl.py", line 144, in getenv
AttributeError: 'module' object has no attribute 'check_output'
error: SublimeREPL: obtaining sane environment failed in getenv()
Check console and 'getenv_command' setting 
WARN: Falling back to SublimeText environment

It seems that the python version (2.6.8) bundled with sublime text doesn't support the check_output call. Am I missing something here? I installed everything as described in the installation instructions. SublimeREPL should work out of the box (and not generate errors and pop-ups) on the most recent version of SublimeText 2 under OS X, shouldn't it?

sorig avatar Mar 05 '14 22:03 sorig

I'm also seeing this. Did you ever find a solution @sorig?

pietvanzoen avatar Sep 25 '14 22:09 pietvanzoen

Same issue! Any solution?

ghost avatar Mar 08 '15 02:03 ghost

Upgrade to Sublime Text 3 if possible.

wuub avatar Mar 09 '15 09:03 wuub

Yes, I'll do it, Thanks!

ghost avatar Mar 09 '15 09:03 ghost

This bug affects latest version also. I analysed the issue and the bug might be related to this http://stackoverflow.com/questions/33643393/sublimerepl-getenv-failing/33651248#33651248

develucas avatar Nov 11 '15 13:11 develucas

@sorig and @pletvanzoen did you guys ever find a solution for this bug? I'd like to develop some python using sublime but getting this error and then just 'REPL closed'.

codyhowarth avatar Nov 14 '15 21:11 codyhowarth

I use sublimeREPL to write python for half of year, but I just got this error this week. It is wired...Anyone help? I really like SublimeREPL!

jasonzhang8801 avatar Nov 14 '15 21:11 jasonzhang8801

I'm having the same problem.

Actually, I've been happily using sulimeREPL without this for a long time, but suddenly(maybe after OX X El Captain update?) I'm having this.

Other than the error message, I have 2 more problems.

  1. the working directory is weird, so I have to change it.
  2. source buffer keys works, but don't give me echos I used to have.

Any solution?

totuta avatar Nov 15 '15 16:11 totuta

Oh yes, forgot to mention that I'm getting this behaviour on OS X El Captain but also on Linux (Ubuntu), so I don't think it's confined to mac only. Although it may have something do with using python 2.7? Or whatever the default is.

If no one finds a solution, when I have time I'll look into forking and fixing myself and let you guys know. It seems like it shouldn't be that bad to fix, just a mismatch between versions or something similar.

codyhowarth avatar Nov 15 '15 16:11 codyhowarth

Same error persisting. Any solutions yet?

paulkr avatar Nov 17 '15 04:11 paulkr

Hi @paulkr, I have not dug deep enough to find a true fix. However, I did find a way to get it to be functional - even though it still throws the error message, it seems to work as intended.

Go to Preferences>Browse Packages, then open the file SublimeREPL/config/Python/Main.sublime-menu. Look for the JSON entry with "id": "rep_python_run", within that entry add an "i" to the cmd field so that it looks like this "cmd": ["python", "-u", "-i", "$file_basename"]. This keeps REPL open after running a python file instead of closing it.

Hope that helps :smile:

codyhowarth avatar Nov 18 '15 15:11 codyhowarth

Same problem here, anyone had fixed this? I tried the solution http://stackoverflow.com/questions/33643393/sublimerepl-getenv-failing/33651248#33651248 but not worked for me.

It used to work properly for me but after I upgrade the system recently it is broken, not sure why. I uses OSX EI Capitan with Sublime Text 2.

nemofang avatar Nov 23 '15 13:11 nemofang

I would also like to add that I am getting the same error message when starting the Haskell REPL but it starts nonetheless. However, running any shell commands via :!cmd in the REPL doesn't work, and neither does tab completion.

spectralLabs avatar Nov 29 '15 19:11 spectralLabs

Hi All,

My patch works in Sublime Text 3 on OSX El Capitan. Does this work for you?

gniquil avatar Dec 02 '15 02:12 gniquil

@gniquil, thank you very much for trying that.

I tested your fix on my SublimeText2, but didn't work.

totuta avatar Dec 02 '15 02:12 totuta

Hi @totuta,

I am actually interested to know how did you try my fix? Since there's no automated tests whatsoever. I literally had to go into my local packages folder and c/p my fix into the file and experiment by restarting SB3 (too) many times. Is this what you do too? Wondering if I am doing this right.

gniquil avatar Dec 02 '15 02:12 gniquil

@gniquil,

Yes, I've done exactly the same thing.

totuta avatar Dec 02 '15 04:12 totuta

Hey @gniquil I tried ur patch of subprocess_repl.py by copying and pasting, but initially it didn't work for me because I stupidly put a stupid little "echo 'yo'" line in my ~/.bash_profile for testing, however I removed that line and it works perfectly. I would suggest to anyone with this problem, to try gniquil's patch by going into your sublime packages directory and copying and pasting the patched python code into subprocess_reply.py https://github.com/wuub/SublimeREPL/issues/458 Thanks!

d3v-null avatar Dec 27 '15 08:12 d3v-null

Fixed for me: http://stackoverflow.com/questions/33643393/sublimerepl-getenv-failing

Don't know if there are any side effects, but I'm using the REPL for F# and it is working fine. Sublime Text 2 on OS X Yosemite

Wonder why SublimeREPL is not found by Sublime Text's package control anymore.

lborg019 avatar Jan 14 '16 23:01 lborg019

If I run "/bin/bash --login -c env" at a Terminal prompt, I get my environment listed.

So,Preferences > Package Settings > SublimeREPL > Settings - User, do something like this: { "getenv_command": false }

Hellengo avatar Feb 17 '16 08:02 Hellengo