Can't open input file: zsh - zsh

I'm trying to execute a .zsh script on Macos big sur and it's not letting me.
Whenever I run the .zsh in terminal, it says "/bin/zsh: can't open input file: file-name.zsh"
I already did brew install zsh prior to this so I'm a bit confused.
Any help would be greatly appreciated. Thanks!

In macOS Transparency Consent and Control (TCC) restricts access to "personal" data, including anything in a user's Desktop folder and outputs a /bin/zsh: can't open input file error message if you try to disobey this rule. Try moving file-name.zsh to a different folder, and if moving file-name.zsh to another folder doesn't help refer to file-name.zsh by using the full path to file-name.zsh.

Figured it out for ZSH on Mac! To get scripts to run from any relative directory, you can first append the rest of the path to the front of the script name and then run as usual:
BASEDIR=$(dirname "$0")
echo "Script location: ${BASEDIR}"
cd "$(dirname "$0")"
$BASEDIR/<script_name>.command
This is currently working for me on macOS Monterey.
(Copied from comment to Karel's answer about macOS ZSH + TCC policy)

Related

Mac OS 11.2.1 Big sur- git version control Rstudio path -unable to edit . Not able to link

I am new to Version control and this is my first attempt. I am also a novice in R. just did an online course. I have installed Git and was trying to add the Version control through Rstudio Global options. The Git executable file path shows "user/bin/git" But when I go to create a Project>version control>Git- I get an error "Git was not detected on the path" I dug deeper and ran cmd in the mac terminal- which git and got the location as "/usr/local/bin/git", I also did a $ git --exec-path and got the location as "/usr/local/Cellar/git/2.30.0/libexec/git-core" I understand the executable path is somewhere else. I understand that I need to change the path but Rstudio is not allowing the changing of the path, and I am unable to edit the path to "/usr/local/Cellar/git/2.30.0/libexec/git-core" from "user/bin/git". I tried manually entering but that doesnt work, I browsed through the file s and sub folders and selected the executable file location , but it still doesnt change. Please help.
Welcome to stackoverflow: You can find a step by step support on the official support site of rstudio. Here you get detailed instructions on how to use version control with RStudio: https://support.rstudio.com/hc/en-us/articles/200532077-Version-Control-with-Git-and-SVN

No such directory or file - Mac

I'm pretty rookie to this, but I managed to get this code running when I had a PC.
Now I want to get this working on my MacBook.
I'm using Rclone to sync to Jottacloud, and I want to make a clickable file, just as a .bat file in windows.
This is my simple code:
#!/bin/bash
cd /
cd /Applications/rclone
rclone copy /Users/windsvendsen/Pictures/Billedebank Jottacloud:Billedebank
Running it in Terminal, without the #!/bin/bash, it works as it should.
But when I save it as a file, without extension, and running chmod 744 on it, it returns with the error "No such file directory"
And here does my knowledge end.
It is probably a pretty simple problem, but I do not manage to get the essence out of my google searches.
Thanks in advance!
Can you do ls on the directory and see if the file actually got created

Custom home not working when console run manually (cygwin)

I was trying to set a new home directory for Cygwin, but the thing is I've managed to do so only partially.
I changed the 'db_home:' parameter (cygwin64/etc/nsswitch.conf) to '/windows' so it now matches the win10 default home folder, but the trick works only if mintty.exe was run through cmd.
Running mintty manually with a desktop shortcut results with the very same default directory as if the file was never changed.
Having all that said, I'm a total newbie when it comes to both Cygwin and Unix in general, so it's very likely I missed something obvious.
I appreciate any help provided, thanks in advance.

Running newer version of R from terminal when older version is invoked by default

I'm trying to run R from iTerm on an OSX computer (OSX 10.11.6). When I enter R, it opens up an older version of R, from the path /Users/***/miniconda2/bin/R. I would like it to run, by default, an R version found at /usr/local/bin/R, without having to enter the full path every time. How would one go about changing the location of the default R?
Thanks for your help
This is likely due to the PATH variable preferring ~/miniconda2/bin before /usr/local/bin. I'm giving you a few options here to help understand why it is happening.
Let's assume your PATH looks like this:
/Users/me/bin:/Users/me/miniconda2/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Modify PATH
You could modify PATH to move /Users/me/miniconda2/bin after /usr/local/bin or remove it from PATH completely. The downside is that if you rely on other binaries in ~/miniconda2/bin they will no longer be found when executing them by name.
Move R out of the way
Another option would be to move ~/miniconda/bin/R out of the way, for example using
mv ~/miniconda/bin/R ~/miniconda/bin/R-miniconda
Afterwards R will be run from the next location in $PATH, but if you update miniconda2 it may return.
Link to R further up in the PATH (easiest/best)
Finally, you could make sure that there is an R executable in something that is further up the $PATH. This is probably the easiest and most effective option.
First, make sure you have a bin folder in your home directory. If this is not the case, create it using mkdir ~/bin and then restart the terminal. The restart should cause the code in ~/.profile to add that folder to your $PATH. You can verify by doing echo $PATH. If this is not the case, add the following line to your ~/.profile or ~/.bash_profile:
export PATH=$HOME/bin:$PATH
In the example at the top, the PATH already contains /Users/me/bin at the beginning of the line (highest priority).
Next, create a soft link to the R binary in the newly created folder:
ln -s /usr/local/bin/R ~/bin/R
You should now be able to execute R, which will prefer the softlink created, which will execute the one you like. If it does not work right away execute hash -r or restart the terminal.
Just in case you happen to be using RStudio Server (open source) or someone is looking for how to change the RStudio Server default version of R, here is what I found when trying to answer the same question:
Starting in RStudio Server 1.3 (the newest version is 1.4.1106, released February 22, 2021), a user’s preferred version of R can be specified in the rstudio-prefs.json file in the global-level /etc/rstudio folder or in the user-level ~/.config/rstudio folder.
See https://blog.rstudio.com/2020/02/18/rstudio-1-3-preview-configuration/ and https://docs.rstudio.com/ide/server-pro/session-user-settings.html for user setting options in newer versions of RStudio Server.
See https://support.rstudio.com/hc/en-us/articles/200716783-RStudio-Release-History for RStudio release history and https://www.rstudio.com/products/rstudio/download-server/redhat-centos/ for Red Hat downloads of the newest version of RStudio Server.

Rstudio Git bash pop-up every time

I have integrated the git version control to an existing project in Rstudio(Windows). After that for every change I make in the Rmd file, a pop up is coming. I could see that it is a git bash executing on every command I have added in the file. I do not have more details on this.
Actually solved it myself just now with the help of this info:
https://stat545-ubc.github.io/git03_rstudio-meet-git.html
WARNING: On Windows, do NOT use C:/Program Files (x86)/Git/cmd/git.exe. The difference between the good and bad paths is bin vs. cmd.
My Rstudio-version was setting the cmd/git.exe as default.
If you change that to bin/git.exe my problem was solved...

Resources