run sage directly from terminal

1,551 views
Skip to first unread message

arshpreet singh

unread,
May 18, 2012, 1:59:35 PM5/18/12
to sage-s...@googlegroups.com
hello sage and sage users

i want to run sage directly from terminal by typing sage so for this i
changed the SAGE_ROOT path in sage script and placed it to
/usr/local/bin but after typing sage in terminal i am getting the
following output.please help to reply this

Error: SAGE_ROOT is set to a bad value:
SAGE_ROOT=/home/mercy-machine/sage
You must correct it or erase it and run this script from the SAGE_ROOT
or SAGE_ROOT/local/bin/ directory.
Error setting environment variables by running
"/home/mercy-machine/sage/local/bin/sage-env";

--
Thanks
Arshpreet singh

http://arshpreetsingh.wordpress.com/

kcrisman

unread,
May 18, 2012, 2:15:25 PM5/18/12
to sage-s...@googlegroups.com

i want to run sage directly from terminal by typing sage so for this i
changed the SAGE_ROOT path in sage script and  placed it to
/usr/local/bin but after typing sage in terminal i am getting the
following output.please help to reply this


If you just append the right directory to your PATH in a .bashrc or .profile that should work.  I have

export PATH=$PATH:'/Applications/MathApps/' 

(which is where I create a symbolic link to my Sage, but whatever) in my .profile file.  You probably can do something similar.  The error message is telling you that the sage script can only be run from inside its own directory.

arshpreet singh

unread,
May 18, 2012, 2:49:49 PM5/18/12
to sage-s...@googlegroups.com
> If you just append the right directory to your PATH in a .bashrc or .profile
> that should work.  I have
>
> export PATH=$PATH:'/Applications/MathApps/'
>
> (which is where I create a symbolic link to my Sage, but whatever) in my
> .profile file.  You probably can do something similar.  The error message is
> telling you that the sage script can only be run from inside its own
> directory.
thanks for replying but i am beginner linux user it will be very
kindful if you please elaborate that what should i do

kcrisman

unread,
May 18, 2012, 3:16:08 PM5/18/12
to sage-s...@googlegroups.com
Since you talked about moving a script and changing SAGE_ROOT, I figured you were an expert!

You will probably have a file called .profile or .bashrc in your home directory.  It depends on what "shell" you use, or if you have a Mac or Linux, or some other things.  If you add a line exactly like the one I have above, except which says

export PATH=$PATH:'/absolute/path/to/the/sage/home/directory/' 

where only you know where that is, on your computer, then that *should* work.

If you don't have such a file, I am not such an expert myself, and which file to create does depend on the system or what "shell" you use.  Some others may have more concrete information.

Daniel Krenn

unread,
May 18, 2012, 3:25:14 PM5/18/12
to sage-s...@googlegroups.com

I didn't change anything in the directory where Sage is installed. I just added a symbolic link.
You can do the following:
- If your Sage is installed in your home you can make a directory bin in your home, i.e. call "mkdir ~/bin" and then add a symbolic link to sage, i.e. do in ~/bin the following: "ln -s ~/directory/of/sage-installation/sage sage". This creates a symbolic link, which can be called, if you are logged in. (maybe you have to restart your system, so that .profile is executed, such that ~/bin is recognised.).
- If you want a system wide installation, make the symbolic link in /usr/local/bin, i.e. "cd /usr/local/bin" and "ln -s /directory/to/sage-installation/sage sage". Then you can start sage by just typing "sage" anywhere. (on my system Sage is located in /opt/sage).

Daniel

arshpreet singh

unread,
May 18, 2012, 4:28:09 PM5/18/12
to sage-s...@googlegroups.com
>> Since you talked about moving a script and changing SAGE_ROOT, I figured
>> you were an expert!
>>
>> You will probably have a file called .profile or .bashrc in your home
>> directory.  It depends on what "shell" you use, or if you have a Mac or
>> Linux, or some other things.  If you add a line exactly like the one I have
>> above, except which says
>>
>> export PATH=$PATH:'/absolute/path/to/the/sage/home/directory/'
>>
>> where only you know where that is, on your computer, then that *should*
>> work.
>>
>> If you don't have such a file, I am not such an expert myself, and which
>> file to create does depend on the system or what "shell" you use.  Some
>> others may have more concrete information.

apology i did not mentioned before i am using ubuntu 12.04. your
answer still confused me but i will try this in future according to
need. well thanks for you reply. :)

> I didn't change anything in the directory where Sage is installed. I just
<snip>.

> If you want a system wide installation, make the symbolic link in
> /usr/local/bin, i.e. "cd /usr/local/bin" and "ln -s
> /directory/to/sage-installation/sage sage". Then you can start sage by just
> typing "sage" anywhere.
Thanks it worked :)

>(on my system Sage is located in /opt/sage).

is there any good thing to install sage in particular directory(like
/opt/sage)? as i made a directory sage in my home folder and compiled
from source.is it also right way-,please correct me if i am wrong?

Simon King

unread,
May 22, 2012, 4:24:42 AM5/22/12
to sage-s...@googlegroups.com
Dear Arshpreet,

On 2012-05-18, arshpreet singh <ars...@gmail.com> wrote:
>> If you want a system wide installation, make the symbolic link in
>> /usr/local/bin, i.e. "cd /usr/local/bin" and "ln -s
>> /directory/to/sage-installation/sage sage". Then you can start sage by just
>> typing "sage" anywhere.
> Thanks it worked :)
>
>>(on my system Sage is located in /opt/sage).
>
> is there any good thing to install sage in particular directory(like
> /opt/sage)? as i made a directory sage in my home folder and compiled
> from source.is it also right way-,please correct me if i am wrong?

It is (at least partially) a matter of taste. For example, I always
build Sage in an "ordinary" folder in my home directory, not in /opt/
or /bin/ or so.

Also, I do not put it Sage my PATH: I don't want that the command "sage"
starts Sage, because I have different versions of Sage on my computer,
and so I always go to the location of a particular Sage version and
start it locally with ./sage (note the "./").

Other people would perfer to be able to launch Sage globally on the
machine. Then, you could put the sage starter script into
/usr/local/bin/, for example.

By that, I mean the following:
- Build sage (could be in any folder, let's call it SAGE_ROOT; and
could be build from source or by extracting a pre-built binary)
- In the folder SAGE_ROOT, there is a file called "sage". Open it with
any text editor.
- You will see the following at the top:
# Set SAGE_ROOT to the location of the sage install, i.e. the directory
# containing this shell script. If unset, we will try to figure it out
# automatically.
#SAGE_ROOT=/path/to/sage-version
- Remove the "#" from the previous line, and replace
/path/to/sage-version with the correct value, i.e., with the absolute
path to the folder in which you have built sage.
- Save the changes, and then copy the script into (for example)
/usr/bin/. Then, the command "sage" should start Sage.

Will different people work on your computer, or will you be the only
one?

Best regards,
Simon


Reply all
Reply to author
Forward
0 new messages