Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 126231 - env-update doesn't evaluate variables
Summary: env-update doesn't evaluate variables
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - External Interaction (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
: 151544 170381 211087 212335 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-03-14 16:08 UTC by Alexis Lahouze
Modified: 2008-03-06 20:21 UTC (History)
6 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexis Lahouze 2006-03-14 16:08:54 UTC
Hi
I have a variable which needs use of $HOME. 

I created file /etc/env.d/99svn:
SVN_SSH="ssh -i '\$HOME'/.ssh/id_dsa.subversion"

So it works.

But first I wrote :
SVN_SSH=SVN_SSH="ssh -i $HOME/.ssh/id_dsa.subversion"
which seems to be more natural...

with env-update.sh it generated into /etc/profile.env:
SVN_SSH='ssh -i /root/.ssh/id_dsa.subversion'

with python version:
SVN_SSH='ssh -i /.ssh/id_dsa.subversion'
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2006-03-14 17:13:13 UTC
Don't restrict bugs...
Comment 2 SpanKY gentoo-dev 2006-03-15 05:50:57 UTC
why not just use ~/.ssh/...
Comment 3 Alexis Lahouze 2006-03-15 06:57:14 UTC
When I use "~/.ssh/...." I have errors with "svn svn+ssh://...../repos". It says "~/.ssh/id_dsa.subversion: no such file or directory"

Maybe ssh doesn't support ~/ path format?

Comment 4 Simon Stelling (RETIRED) gentoo-dev 2006-04-05 10:21:12 UTC
I would say what you get with env-update.sh is expected behaviour. It's normal that you have to escape variables which you don't want to evaluate immediately. It's a bug though that env-update doesn't evaluate variables at all, IMHO.
Comment 5 Heinrich Götzger 2006-10-10 00:59:17 UTC
(In reply to comment #4)
> It's a bug though that env-update doesn't evaluate variables at all, IMHO.

So would I, as well as the following:

In my case I use in /etc/env.d/99oracle lines like:
ORACLE_BASE=/opt/oracle
ORACLE_HOME=$ORACLE_BASE/product/10.2.0.1.0

and later in the shall I try to use ORCALE_HOME:
echo $ORACLE_BASE"\n"$ORACLE_HOME 
/opt/oracle
$ORACLE_BASE/product/10.2.0.1.0

and it is not working as expected.
Expected would be to have ORACLE_HOME containing:
/opt/oracle/product/10.2.0.1.0

Am I wrong?
Comment 6 Zac Medico gentoo-dev 2006-10-10 15:24:52 UTC
(In reply to comment #4)
> It's a bug though that env-update doesn't evaluate variables at all, IMHO.

Evaluating variables from just within /etc/env.d vs. including the calling environment are two possible ways to go about it.  I could understand the former but the latter seems like a bad idea to me.
Comment 7 Zac Medico gentoo-dev 2006-10-10 15:30:08 UTC
One other thing to consider is that env-update treats some variables as cumulative while others overwrite previous values.  That leads to some ambiguity in how variables should be evaluated.  Should cumulative variables be accumulated before evaluations, during, or after?  After considering this, I thing this bug is a WONTFIX.
Comment 8 Heinrich Götzger 2006-10-11 06:13:59 UTC
So we (or at least I) have a minor conflict:
in http://gentoo-wiki.com/HOWTO_Install_Oracle_10g#Setup_Variables
there is a recommendation about setting variables which will be evaluated immediatly.

So either the how-to, env-update or my understanding is wrong.

Thanks for spending some light on this.
Comment 9 Simon Stelling (RETIRED) gentoo-dev 2006-10-11 08:52:43 UTC
the howto is wrong
Comment 10 Zac Medico gentoo-dev 2006-10-16 10:50:04 UTC
*** Bug 151544 has been marked as a duplicate of this bug. ***
Comment 11 Jakub Moc (RETIRED) gentoo-dev 2007-03-11 09:47:08 UTC
*** Bug 170381 has been marked as a duplicate of this bug. ***
Comment 12 email_deleted_GqKU 2007-05-10 16:31:03 UTC
If it really won't be supported, there should be a warning, when running `env-update`, when a variable tries to reference another one (detect "$", if not prefixed with a backslash).

Something like: `ewarn "In file /etc/env.d/example, variable EXAMPLE tries to reference another variable (EXAMPLE2), which is not supported. You should remove the reference, to avoid any problem."`.

The manual should also be updated, to add a more general warning (http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=5 says nothing about it -it just says that some variables will be concatenated, instead of replaced).

As it is counterintuitive, there should really be some more information about it.

I had some problem with a few ebuilds which used the ":=" operator, in makefiles, as Make will try to interpret the referenced variable (as it is kept as is by `env-update`), and if the referenced variable is a reference to itself (for example, in "/etc/env.d/02ccache", I had `ROOTPATH="/usr/lib/ccache/bin:${PATH}"`), Make will halt, with this error: "*** Recursive variable `PATH' references itself (eventually).  Stop."... (see bug #175569 and bug #171171). As "/etc/profile" does not seem to be sourced by my terminal (non-login shell, which does not seem to inherit the login shell environment variables... -well, that's another problem I'll deal with later), it took me some time to understand where was the problem coming from, as my PATH was the default one (which surely should have been a hint, but I didn't get it...), so I thought the problem was coming from the packages themselves... (I thought about some compatibility problem with Make, or something like this...).
Comment 13 Zac Medico gentoo-dev 2007-05-10 19:37:01 UTC
This one is similar to bug 176139 where we have multiple overlapping references.  We have /etc/env.d/ mentioned in at least 2 places:

http://devmanual.gentoo.org/tasks-reference/environment/index.html
http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=5

The Gentoo Developer Handbook avoids duplication by referencing the other handbook for /etc/env.d documentation:

http://www.gentoo.org/proj/en/devrel/handbook/handbook.xml?part=2&chap=1#doc_chap3

The behavior of the special SPACE_SEPARATED and COLON_SEPARATED variables doesn't seem to be officially documented anywhere at the moment.  It's described here:

http://archives.gentoo.org/gentoo-dev/msg_91855.xml
Comment 14 nm (RETIRED) gentoo-dev 2007-05-19 03:05:31 UTC
(In reply to comment #13)
So, does the GDP need to make any changes to any documents in /doc/? Documents not in /doc/ are not our territory, and if there are no changes to make we don't need to be CCed on this.
Comment 15 Zac Medico gentoo-dev 2007-05-19 03:33:09 UTC
For the GDP, I think this part is an occasional source of confusion for users:

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=5#doc_chap2_sect1

It tells users that they can define variables there but it doesn't say anything about what syntax is allowed there.  Sometimes users assume that they can use shell variables in the definition of other variables and that's actually not supported.
Comment 16 nm (RETIRED) gentoo-dev 2007-05-19 04:14:41 UTC
(In reply to comment #15)
Done. Added a note in the handbook forbidding using shell variables to define other variables.
Comment 17 Marius Mauch (RETIRED) gentoo-dev 2007-06-07 14:32:52 UTC
So what's left to do here?
Comment 18 Zac Medico gentoo-dev 2007-06-07 15:09:02 UTC
I think we can close this now.  The warning in the handbook should be enough to prevent confusion.
Comment 19 Jakub Moc (RETIRED) gentoo-dev 2008-02-22 08:54:00 UTC
*** Bug 211087 has been marked as a duplicate of this bug. ***
Comment 20 Jakub Moc (RETIRED) gentoo-dev 2008-03-06 09:12:22 UTC
*** Bug 212335 has been marked as a duplicate of this bug. ***
Comment 21 Justin Patrin 2008-03-06 20:21:50 UTC
I have altered the Oracle HOWTO to show a sample profile.d script instead of the env.d script which included previous variables. The original env.d script with no expansion is still there.