Skip to content

Discover SAGE_SCRIPTS_DIR to make $SAGE_LOCAL/bin/sage work from any directory, in an environment without SAGE_* variables #25486

@mkoeppe

Description

@mkoeppe

This ticket makes $SAGE_LOCAL/bin/sage work without environment variables set, or the current working directory to be something particular.

It does that by

  • adding SAGE_ROOT to $SAGE_LOCAL/bin/sage-env-config (via src/bin/sage-env-config.in).
  • adding code to the top of sage-env that determines SAGE_SCRIPTS_DIR from the directory of itself.

Previous discussion in https://groups.google.com/d/msg/sage-devel/oODph9-yjaI/FVeBsCk_CgAJ:

On Wednesday, May 30, 2018 at 9:01:59 AM UTC-7, Nils Bruin wrote:

Currently, if I run the script $SAGE_LOCAL/bin/sage in my normal environment (where SAGE_ROOT is not set) then I get:

Error: You must set the SAGE_ROOT environment variable or run this
script from the SAGE_ROOT or SAGE_ROOT/local/bin/ directory.
Error setting environment variables by sourcing '/usr/local/sage/sage-git/local/bin/sage-env';
possibly contact sage-devel (see http://groups.google.com/group/sage-devel).

If instead I run the script $SAGE_ROOT/sage a value for SAGE_ROOT is figured out and everything works
fine when called from my normal environment.

CC: @jdemeyer @nbruin @embray @kiwifb @EmmanuelCharpentier @tobihan @saraedum @slel @timokau @dimpase

Component: build

Keywords: SAGE_LOCAL, SAGE_ROOT

Author: Matthias Koeppe

Branch: 4415da5

Reviewer: Dima Pasechnik

Issue created by migration from https://trac.sagemath.org/ticket/25486

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions