Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors thrown by activate.fish #8

Closed
vbabiy opened this issue Mar 14, 2011 · 15 comments
Closed

Errors thrown by activate.fish #8

vbabiy opened this issue Mar 14, 2011 · 15 comments
Labels

Comments

@vbabiy
Copy link

vbabiy commented Mar 14, 2011

I'm getting a bunch of errors using the activate script for Fish (many thanks for supporting this minority shell!).

wilfred@Tenor ~/py-envs> . app-engine/bin/activate.fish 
fish: Unknown command “tempfile”
/home/wilfred/py-envs/app-engine/bin/activate.fish (line 1): tempfile
                                                             ^
in command substitution
    called on line 46 of file “/home/wilfred/py-envs/app-engine/bin/activate.fish”,

in . (source) call of file “/home/wilfred/py-envs/app-engine/bin/activate.fish”,
    called on standard input,

fish: Expected redirection specification, got token of type “$oldpromptfile”
/home/wilfred/py-envs/app-engine/bin/activate.fish (line 49):         echo "function _old_fish_prompt" >> $oldpromptfile
                                                                                                          ^
in . (source) call of file “/home/wilfred/py-envs/app-engine/bin/activate.fish”,
    called on standard input,

wilfred@Tenor ~/py-envs> fish --version
fish, version 1.23.1
wilfred@Tenor ~/py-envs> virtualenv --version
1.5.1

Things still seem to work as expected, but the prompt doesn't change.

Cheers.


@vbabiy
Copy link
Author

vbabiy commented Mar 14, 2011

Ah. My bad. The script's call to "tempfile" fails
(http://manpages.ubuntu.com/manpages/lucid/man1/tempfile.1.html), so it
doesn't generate the temporary file for the old prompt, and everything falls
apart from there.

I'll change this to something more standard. It looks like mktemp is the
favoured way of doing the same thing?

If you swap that line in activate.fish (line 49), from:

set -l oldpromptfile (tempfile)

to:

set -l oldpromptfile (mktemp)

does it start working for you?


Original Comment By: Christopher Nilsson

@vbabiy
Copy link
Author

vbabiy commented Mar 14, 2011

I've pushed some updates to my fork, over at:
http://bitbucket.org/otherchirps/virtualenv .

It should now use mktemp, instead of tempfile. Hopefully that's more
widespread. Also, should mktemp be unavailable, it will fallback to a simple
prompt change. (There'll still be an error, complaining about mktemp not being
found, but at least it won't just bomb out without letting you know the
virtual env vars are "in play".)

From what I can tell, it seems to fix the problem.

Please review. If all is well, I'll send a pull request.


Original Comment By: Christopher Nilsson

@vbabiy
Copy link
Author

vbabiy commented Mar 14, 2011

Works like a charm.


Original Comment By: Wilfred

@vbabiy
Copy link
Author

vbabiy commented Mar 14, 2011

On OSX, mktime doesn't work like on linux (not the same arguments). The only
portable way is to use python: python -c 'import tempfile;print(tempfile.mkstemp()[1])'


Original Comment By: chs

@vbabiy
Copy link
Author

vbabiy commented Mar 14, 2011

Ah...

I don’t have a Mac available, so perhaps someone else can confirm this for me.
Judging by the docs it looks that on Mac OS X (and in turn, some of the
BSDs), mktemp requires a mandatory argument. Either you have to supply a
full filename template, or use the -t flag, which will append the given
filename pattern to the $TMPDIR. eg. "mktemp -t foo.XXX" gives
"/tmp/foo.ulG".

For linux & friends using the GNU Coreutils implementation (which is what
I tested under), mktemp doesn’t require any arguments, since it will happily
assume an implicit -t with a default value.

Spinning up a python interpreter, as suggested, would work well. However, it’s
probably lighter to simply supply the optional arguments (eg. “mktemp -t tmp.oldpromptcontents.XXXX”, or something), since this should work across all
these platforms as well. I’ve uploaded this change to my fork, as before. Let
me know if it works for you or not.

Of course, if my reading of this is wrong, calling on python will probably be
the best way to go. Definitely portable. And since we’re trying to activate a
virtualenv, it’s a safe bet python is available. :)

/ManPages/man1/mktemp.1.html

invocation.html#mktemp-invocation


Original Comment By: Christopher Nilsson

@KangOl
Copy link

KangOl commented May 12, 2011

it work with mktemp -t tmp.oldpromptcontents.XXXX

@maxcountryman
Copy link

+1 would be great to see this patched

@carljm
Copy link

carljm commented Apr 3, 2012

Fixed in 9be1f43 - thanks @dsc.

@carljm carljm closed this as completed Apr 3, 2012
@dsc
Copy link

dsc commented Apr 6, 2012

Sorry I didn't reply earlier -- I couldn't get to the bottom of the reason for the changes to ez_setup.py and then it fell off my plate. Great to see it merged into master!

@skeet70
Copy link

skeet70 commented Nov 3, 2012

I'm still having a problem with this, heres what I get when running . bin/activate.fish with both fish 1.23.1 and beta r2 fishfish and virtualenv 1.8.2:

fish: Could not locate end of block. The 'end' command is missing, misspelled or a ';' is missing.
/private/tmp/.psub.99273.11049 (line 1): function _old_fish_prompt
                                         ^
in . (source) call of file '/private/tmp/.psub.99273.11049',
    called on line 50 of file '/env/research_experiment/django_apache/bin/activate.fish',

in . (source) call of file '/env/research_experiment/django_apache/bin/activate.fish',
    called on standard input,


       function − function ‐ create a function

function ‐ create a function
   # snipped fish man page on function

.: Error while reading file '/private/tmp/.psub.99273.11049'
fish: Unknown command '_old_fish_prompt'
/env/research_experiment/django_apache/bin/activate.fish (line 57): _old_fish_prompt
                                                                    ^
in command substitution
    called on line 69 of file '/env/research_experiment/django_apache/bin/activate.fish',

in function 'fish_prompt',
    called on standard input,

in command substitution
    called on standard input,

Environment is successfully set up though, and prompt changes to a blue (env_name). Every command works but throws:

(django_apache)virtualenv --version
1.8.2
fish: Unknown command '_old_fish_prompt'
/env/research_experiment/django_apache/bin/activate.fish (line 57): _old_fish_prompt
                                                                    ^
in command substitution
    called on line 69 of file '/env/research_experiment/django_apache/bin/activate.fish',

in function 'fish_prompt',
    called on standard input,

in command substitution
    called on standard input,

Something I need to change, or a bug?

@gabriel4649
Copy link

I'm getting the same errors as skeet70

@sumeet
Copy link

sumeet commented Jan 16, 2013

confirmed, same error. i'm on snow leopard, virtualenv 1.8.2 and python 2.6.

@mcassiano
Copy link

Keeps throwing error below in every command.
Mountain Lion running virtualenv 1.9.1

.: Error encountered while sourcing file ' -- psub -Q -o hf --':
.: Value too large to be stored in data type
fish: Unknown command '_old_fish_prompt'
/Users/matheus/Desktop/work/env/bin/activate.fish (line 57): _old_fish_prompt
                                                                ^
in command substitution
    called on line 69 of file '/Users/matheus/Desktop/work/env/bin/activate.fish',

in function 'fish_prompt',
    called on standard input,

in command substitution
    called on standard input,

@gabriel4649
Copy link

For Fish users I would recommend to just move to Virtual Fish, it works really great. I never got this to work but Virtual Fish works flawlessly.

@mcassiano
Copy link

I'll check it out. Thanks :)

@rtd-helper rtd-helper bot mentioned this issue Oct 16, 2019
@pypa pypa locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

9 participants