After installing R using homebrew on mac following the instructions from here : https://www.datacamp.com/community/tutorials/installing-R-windows-mac-ubuntu . When I open the terminal I get these :
-bash: /Users/myname/.bash_profile: line 27: syntax error near unexpected token `category="LC_ALL",'
-bash: /Users/myname/.bash_profile: line 27: `Sys.setlocale(category="LC_ALL", locale = "en_US.UTF-8")'
so how could I fix/get rid of these from appearing on the terminal .
I think this has something to do with :
$ echo "export LC_ALL=en_US.UTF-8" >> ~/.bash_profile
$ echo "export LANG=en_US.UTF-8" >> ~/.bash_profile
$ echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile && source ~/.bash_profile
The instructions that you link to say to do this in Step 3 to add stuff to your ~/.bash_profile:
echo 'Sys.setlocale(category="LC_ALL", locale = "en_US.UTF-8")' >> ~/.bash_profile
I think that is wrong. That is R code, not bash code, so it shouldn't go in ~/.bash_profile. It should go in ~/.Rprofile instead.
Remove line 27 (the one that says Sys.setlocale(...)) from your ~/.bash_profile and add it to your ~/.Rprofile file instead.
And then send DataCamp an email telling them that their R installation instructions have a significant error in them.
Related
I often happen to run a command like source mydirectory, where mydirectory is a ...directory, and not a shell script file (I guess I'm not that good at predicting autocompletion :p)
What puzzles me is that zsh does not complain, and returns 0 as status code; although that does not seem a normal call to source AFAIK.
# in zsh shell
# create an empty dir
$ mkdir /tmp/mydir
# "source" it
$ source /tmp/mydir && echo "success"
# output: 'success'
Meanwhile, bash will complain when asked to "source"
# in bash
$ source /tmp/mydir/ && echo "success"
# output: 'bash: source: /tmp/mydir/: is a directory'
Does someone know why this is a valid call in ZSH?
References I looked in
SO itself
the documentation of ZSH builtin commands https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Commands.html
multiple tutorials about source
... to no avail
I have a '.js' script that I usually activate from the terminal using the command node script.js. As this is part of a process where I first do some data analysis in R, I want to avoid the manual step of opening the terminal and typing the command by simply having R do it for me. My goal would be something like this:
...R analysis
write.csv(df, "data.csv")
system('node script.js')
However, when I use that specific code, I get the error:
sh: 1: node: not found
Warning message:
In system("node script.js") : error in running command
Of course, the same command runs without problem if I type it directly on the terminal.
About my Software
I am using:
Linux computer with the PopOS!
RStudio 2021.09.1+372 "Ghost Orchid"
R version 4.0.4.
The error message node: not found indicates that it couldn't find the program node. It's likely in PATH in your terminal's shell, but not in system()'s shell (sh).
In your terminal, locate node by executing which node. This will show the full path to the executable. Use that full path in system() instead.
Alternatively, run echo $PATH in your terminal, and run system('echo $PATH') or Sys.getenv('PATH') in R. Add any missing directories to R's path with Sys.setenv(PATH = <your new path string>)
Note that system2() is recommended over system() nowadays - but for reasons unimportant for your case. See ?system and ?system2 for a comparison.
Examples
Terminal
$ which node
/usr/bin/node
R
system('/usr/bin/node script.js')
# alternatively:
system2('/usr/bin/node', c('script.js'))
or adapt your PATH permanently:
Terminal
% echo $PATH
/usr/local/bin:/home/caspar/programs:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
R
> Sys.getenv('PATH')
[1] "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Applications/RStudio.app/Contents/MacOS/postback"
> Sys.setenv(PATH = "/home/caspar/programs:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Applications/RStudio.app/Contents/MacOS/postback")
I installed zsh on my mac but I get this error when I try to source it:
Last login: Sat Nov 20 15:54:12 on ttys004
➜ ~ source zsh
[2] 55808
/usr/local/bin/zsh:1: parse error near `)'
/usr/local/bin/zsh:1: bad pattern: ^#^#^#^#^#^Y^#^#^#H^#^#^#__PAGEZERO^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^A^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^Y^#^#^#(^B^#^#__TEXT^#^#^#^#^#^#^#^#^#^#^#^#^#^#^A^#^#^#^##^H^#^#^#^#^#^#^#^#^#^#^#^#^#^##^H^#^#^#^#^#^E^#^#^#^E^#^#^#^F^#^#^#^#^#^#^#__text^#^#^#^#^#^#^#^#^#^#__TEXT^#^#^#^#^#^#^#^#^#^#\M-<O^#^#^A^#^#^#\M-q
/usr/local/bin/zsh:1: parse error in command substitution
[2] + 55808 exit 1 ����X�
I copied the zshrc.zsh-template from templates as my .zshrc file so I don't even know if the problem is with zsh. It just happens when I run source zsh. I can't figure out what causes this or how to fix it.
The proper source command is source ~/.zshrc
When I open terminal, I receive this message:
Last login: Fri Jan 17 11:02:25 on ttys000
(eval):1: parse error near `)'
(eval):1: parse error near `)'
It prints twice, but I only have four ")" in my .zshrc file, and none of them seem to be causing any issues. I've looked around the web for solutions, but I haven't found many that seem to address this problem.
My .zshrc file looks like this:
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
(Some code removed for brevity...)
# Which plugins would you like to load?
source $ZSH/oh-my-zsh.sh
# My personal Add-ons:
# open VSCode via "code"
function code {
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
local argPath="$1"
[[ $1 = /* ]] && argPath="$1" || argPath="$PWD/${1#./}"
open -a "Visual Studio Code" "$argPath"
fi
}
Thanks!
I am using cygwin on windows 7 env and it is unable to locate java, error message i get is that
ERROR: /cygdrive/c/Program
Files/Java/jdk1.6.0_22 does not exist!
wired path is if I do echo $JAVA_HOME then it shows me
$ echo $JAVA_HOME
/cygdrive/c/Program Files/Java/jdk1.6.0_22
not sure what is happening here, any suggestions?
The problem is that the pathname contains spaces. You need to escape the spaces as described here:
http://www.cygwin.com/faq/faq.using.html#faq.using.filename-spaces
Adding this line to your .bashrc should do it:
export JAVA_HOME='/cygdrive/c/Program Files/Java/jdk1.6.0_22'
Edit: You could try running this script which I found in this blog post:
case "`uname`" in
CYGWIN*) cygwin=true ;;
esac
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
JAVA_HOME=`cygpath --windows "$JAVA_HOME"`
CLASSPATH=`cygpath --windows --path "$CLASSPATH"`
fi
Use the old school way:
export JAVA_HOME=/cygdrive/c/Progra~1/Java/jdk1.6.0_22
It worked for me.