Installation for SCT version 6.2 failed (with macOS Sonoma 14.3) - ".bash_profile: Permission denied"

Dear @jcohenadad and SCT Team,

I was trying to install SCT version 6.2 (no prior versions installed before) and the installation failed.

I checked that gcc and Rosetta2 were installed first and it were. I tried the option 1 (install from package) and the option 2 (Install from GitHub).

Please find attached the file “install_sct_log.txt”

Could you help me please ?

Best regards

install_sct_log.txt (2.3 KB)

Dear Mathilde,

Thank you for reporting this failure! We have received previous reports of this failure, summarized in Issue #3622 on our bug tracker. I will update the issue with your new report, too.

To summarize, though, the failure is due to the requirement that the user running the script should have read permissions for the file “.bash_profile” in your home directory.

You can double check the status of permissions by running:

ls -lah ~/ | grep bash_profile

Then, I believe this can be fixed by modifying the read permissions of this file by running the following command:

chmod +r ~/.bash_profile

You should see a change in the output of ls after running this command. Can you try this, then re-run the installer?

Thank you kindly,

1 Like

Dear Joshua,

Many thanks for your prompt reply and your help !

I’m really sorry, when I ran these two commands, it didn’t work out. It seems to me the read permissions haven’t changed.
Then, I tried to read and look into several issues, and in Issue #4099 (Installation failed Permission denied on .bash_profile · Issue #4099 · spinalcordtoolbox/spinalcordtoolbox · GitHub) the same problem has been solved by running “sudo ./install_sct” instead of “./install_sct”. Therefore, I tried to re-run the installer with “sudo” and, consequently, SCT installation worked out.
Moreover, after successful installation, I read the comment (Issue #4099) from a member of the SCT Team, and he doesn’t really advise this solution. Maybe I shouldn’t have done it that way. What do you think about it ?

Best regards,

Installation_SCT.txt (70.3 KB)

1 Like

I agree with my colleague’s concerns, and I would not generally recommend installing SCT with sudo.

This is very useful feedback, thank you! I also very much appreciate that you shared the full output of the commands in your text log. This is very helpful for me, so thank you. :slight_smile:

(base) MacBook-Pro-de-Mathilde:~ mathilde$ ls -lah ~/ | grep bash_profile
-rw-r--r--     1 root      staff   463B  7 fév 15:46 .bash_profile

This gives us a hint! The file .bash_profile is owned by the root user. But, given that you are currently working as the mathilde user, some operations may not work (since you are not root).

However, I’m not sure this should matter in this specific case. Because, the “others” section of the file permission shows that “others” should have read permission (r--).

So, perhaps this issue is no longer just about read permissions anymore? Looking at the line 273 referenced in the error log, it is:

273        echo "$sourceblock" >>"$profile"

Aha! So, our script requires write permissions, too! This must have changed in the years since the original issue was written.

In that case, I would amend my previous advice to run the following command instead:

sudo chown mathilde ~/.bash_profile

This command should change the ownership of the .bash_profile file (this change can be observed in the ls output → it should change from root to mathilde, which will enable writing for your user account). Then, you should be able to run install_sct without needing to use sudo.

(That said, I will update our internal issue tracker to discuss this new issue of requiring write permissions. Hopefully we can come up with a better longterm solution for this issue.)

Kind regards,

1 Like

Hello Joshua,

I apologize for my very late reply.
I tried the command “sudo chown mathilde ~/.bash_profile” but it still doesn’t seem to work… I’m really sorry.

Many thanks for your help.

Kind regards,

install_SCT.txt (62.3 KB)

Hi @Brd,

No worries about the late reply! There is some good news – the chown command did work, as the new log you’ve sent shows some new progress!! :tada:

Now, instead of failing on the ~/.bash_profile step, SCT actually successfully installs, and the installer script only fails at the very end of the installation (when the installer script tries edit a different file called ~/.bashrc). So, you actually have a fully installed copy of SCT; the only thing left is editing ~/.bashrc to make the commands available on the terminal.

My best guess is that this is the same problem: your user account doesn’t own ~/.bashrc, and thus the install script cannot write to it. (You can test this by trying to open the ~/.bashrc file using a text editor.)

To solve this problem:

  1. Run “sudo chown mathilde ~/.bashrc” (to take ownership of the .bashrc file)
  2. Run “open ~/.bashrc” to open the file in a text editor
  3. Copy and paste the following text at the end of the file, then save it.
    # SPINALCORDTOOLBOX (installed on 2024-04-10)
    export PATH="/Users/mathilde/spinalcordtoolbox/bin:$PATH"
    export SCT_DIR=/Users/mathilde/spinalcordtoolbox
    (The purpose of these lines is to ensure that you can call the various SCT commands from the terminal.)
  4. Run “source ~/.bashrc” to re-load this new configuration.
  5. Run the SCT command “sct_check_dependencies” to confirm that the installation worked.

Thank you for your patience as we try to resolve this issue. :hearts:

Kind regards,

1 Like

Hello Joshua,

Thanks again for your help. You always find solutions, it’s wonderful ! :smiley:

I understand your explanations and the problem. In fact, I have studied the script I sent you last time and I saw the line that said “./install_sct: line 286: /Users/mathilde/.bashrc: Permission denied”.

Therefore, I followed your advice and It seems to have worked completely now. What do you think ?
In the attached file, there aren’t all the commands you advised me to run because I ran them yesterday and I forgot to save my script sorry !

Have a nice day

Kind regards,

install_SCT_success?.txt (50.8 KB)

Terminal Saved Output.txt (54.4 KB)

Thank you so much for the kind words! :hearts:

Therefore, I followed your advice and It seems to have worked completely now. What do you think ?

This is perfect! You should be free to use SCT now. :slight_smile:

If you have any further questions or concerns regarding the usage of SCT, feel free to open a new forum post and our team will be happy to help. :slight_smile:

Kind regards,

Just as one final little note: “.bashrc” is a useful little file that is designed to be modified by users to customize their Terminal. So, all of what we’ve done so far (e.g. taking ownership of the file, adding new SCT-specific lines) is perfectly safe and ordinary – in fact, that’s what the file is meant for! :slight_smile:

1 Like