Bug 492706 - /etc/profile.d/R.sh and /etc/profile.d/R.csh breaks shell environment
Summary: /etc/profile.d/R.sh and /etc/profile.d/R.csh breaks shell environment
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: R
Version: 10
Hardware: All
OS: Linux
low
high
Target Milestone: ---
Assignee: Tom "spot" Callaway
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-03-28 16:26 UTC by Edgar Hoch
Modified: 2009-03-31 20:36 UTC (History)
1 user (show)

Fixed In Version: 2.8.1-8.fc10
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-03-31 20:34:43 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Patch for src/scripts/R.sh.in (found in R-2.8.1-7.fc10.src.rpm in the expanded R-2.8.1.tar.gz) (544 bytes, patch)
2009-03-28 16:26 UTC, Edgar Hoch
no flags Details | Diff
Patch for /etc/profile.d/R.sh (found in R-2.8.1-7.fc10.src.rpm as R.sh) (529 bytes, patch)
2009-03-28 16:27 UTC, Edgar Hoch
no flags Details | Diff
Patch for /etc/profile.d/R.csh (found in R-2.8.1-7.fc10.src.rpm as R.csh) (588 bytes, patch)
2009-03-28 16:28 UTC, Edgar Hoch
no flags Details | Diff

Description Edgar Hoch 2009-03-28 16:26:07 UTC
Created attachment 337113 [details]
Patch for src/scripts/R.sh.in (found in R-2.8.1-7.fc10.src.rpm in the expanded R-2.8.1.tar.gz)

Description of problem:
R-core-2.8.1-7.fc10.x86_64 was installed by yum-updatesd. There are new files:
/etc/profile.d/R.sh
/etc/profile.d/R.csh

If environment variable R_HOME is already set to a value other than the value used by R, then `R RHOME` produces a warning:

$ R RHOME
WARNING: ignoring environment value of R_HOME
/usr/lib64/R

The result is that the setting of R_HOME in /etc/profile.d/R.sh and /etc/profile.d/R.csh gets a wrong value (in case of bash) or produces a syntax error from setenv (in case of tcsh (csh)).
In case of tcsh (csh) the syntax error stops the execution of the remaining init scripts, which results in an incomplete environment and settings of the tcsh (login) shell.

Here are some results.
Note that the value of R_HOME is
"WARNING: ignoring environment value of R_HOME /usr/lib64/R"
in the error case, and in tcsh
"setenv R_HOME WARNING: ignoring environment value of R_HOME /usr/lib64/R"
procudes a syntax error.

$ bash
$ export R_HOME=
$ bash
$ echo $R_HOME
/usr/lib64/R
$ exit
$ export R_HOME=/usr/local/lib/R
$ bash
$ echo $R_HOME
WARNING: ignoring environment value of R_HOME /usr/lib64/R
$ exit
$ export R_HOME=/usr/lib64/R    
$ bash
$ echo $R_HOME
/usr/lib64/R
$ exit
$ tcsh
tcsh$ exit
exit
$ export R_HOME=/usr/local/lib/R
$ tcsh
setenv: Too many arguments.
tcsh-incomplete $ exit


How could this be solved?

1. The init scripts /etc/profile.d/R.sh and /etc/profile.d/R.csh
   should not set R_HOME is it is already set
   because it may be that the user has set it on his own.

2. R should write warning messages to standard error and not to standard output.
   The waring message listed above is written to standard output.
   Then `R RHOME` returns only the path and not also the error message.


Version-Release number of selected component (if applicable):
R-core-2.8.1-7.fc10.x86_64

How reproducible:


Steps to Reproduce: See above.

Additional info:
This bug breaks login environment with tcsh as login shell and R_HOME already set.
This is the reason why I declare the severity as high
and why this bug should be fixed very soon.
I provide patches which can be applied to the rpm sources
so a new package can be build and released very soon.

For the future I request the developers to consider and to test all possible standard cases (like the case that a variable is already set) before releasing an script (such as an init script) to the public.
Thanks in advance!

Comment 1 Edgar Hoch 2009-03-28 16:27:56 UTC
Created attachment 337114 [details]
Patch for /etc/profile.d/R.sh (found in R-2.8.1-7.fc10.src.rpm as R.sh)

Comment 2 Edgar Hoch 2009-03-28 16:28:52 UTC
Created attachment 337115 [details]
Patch for /etc/profile.d/R.csh (found in R-2.8.1-7.fc10.src.rpm as R.csh)

Comment 3 Tom "spot" Callaway 2009-03-28 16:42:19 UTC
Wow, that's a nasty bug. Thanks for the quick fixes. The patches for the R.sh and R.csh are obviously correct, but I think with them in place, the patch to  src/scripts/R.sh.in is unnecessary.

I'm going to go ahead and kick off a new set of builds with the fixed profile scripts.

Comment 4 Edgar Hoch 2009-03-28 17:02:28 UTC
Thanks for the quick response!

I agree that for the shell problem the patches for /etc/profile.d/R.{sh,csh} are enough.

But writing warning messages to standard output instead to standard error may break other scripts that start R - like it was the case with the one in /etc/profile.d.
So I think R.sh.in should be checked for other missing redirects to standard error - in a quick skim over R.sh.in I found that the usage message an some debug messages at the end of the file should also be redirected to standard errer.
This are not included in my patch - so this may be done in another update - or better done in the upstream code.

Comment 5 Tom "spot" Callaway 2009-03-28 17:19:55 UTC
If you do work up a patch like this, I'd want it to go to upstream for review first. :)

Comment 6 Fedora Update System 2009-03-28 17:43:07 UTC
R-2.8.1-8.fc9 has been submitted as an update for Fedora 9.
http://admin.fedoraproject.org/updates/R-2.8.1-8.fc9

Comment 7 Fedora Update System 2009-03-28 17:43:13 UTC
R-2.8.1-8.fc10 has been submitted as an update for Fedora 10.
http://admin.fedoraproject.org/updates/R-2.8.1-8.fc10

Comment 8 Fedora Update System 2009-03-31 20:34:38 UTC
R-2.8.1-8.fc9 has been pushed to the Fedora 9 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2009-03-31 20:36:37 UTC
R-2.8.1-8.fc10 has been pushed to the Fedora 10 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.