Skip to content

Commit 44ba181

Browse files
authored
Do not error when PKG installer cannot change file ownership in HOME (#1185)
* Do not error when PKG installer cannot change file ownership in HOME * Fix typo in Windows installer options * Add owner to warnings
1 parent 73331d4 commit 44ba181

4 files changed

Lines changed: 40 additions & 4 deletions

File tree

constructor/nsis/OptionsDialog.nsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Function mui_AnaCustomOptions_Show
173173
${Else}
174174
${NSD_CreateLabel} 5% "$5u" 90% 20u \
175175
"NOT recommended. This can lead to conflicts with other applications. \
176-
Instead, use the Commmand Prompt and Powershell menus added \
176+
Instead, use the Command Prompt and PowerShell menus added \
177177
to the Windows Start Menu."
178178
${EndIf}
179179
IntOp $5 $5 + 20

constructor/osx/run_conda_init.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ if [[ "${USER}" != "root" ]]; then
4040
if [[ -f "${file}" ]] || [[ -d "${file}" ]]; then
4141
OWNER=$(stat -f "%u" "${file}" | id -un)
4242
if [[ "${OWNER}" == "root" ]]; then
43-
chown "${USER}" "${file}"
43+
if ! chown "${USER}" "${file}"; then
44+
MSG="WARNING! Unable to change ownership of ${file} (owned by ${OWNER})."
45+
logger -p "install.warning" "${MSG}" || echo "${MSG}"
46+
fi
4447
fi
4548
fi
4649
file="${file%/*}"

constructor/osx/run_installation.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,22 @@ find "$PREFIX/pkgs" -type d -empty -exec rmdir {} \; 2>/dev/null || :
122122
# This is not needed for the default install to ~, but if the user changes the
123123
# install location, the permissions will default to root unless this is done.
124124
chown -R "${USER}" "$PREFIX"
125-
test -d "${HOME}/.conda" && chown -R "${USER}" "${HOME}/.conda"
126-
test -f "${HOME}/.condarc" && chown "${USER}" "${HOME}/.condarc"
125+
CONDA_DIR="${HOME}/.conda"
126+
if [[ -d "${CONDA_DIR}" ]]; then
127+
if ! chown -R "${USER}" "${CONDA_DIR}"; then
128+
OWNER=$(stat -f "%u" "${CONDA_DIR}" | id -un)
129+
MSG="WARNING: Unable to change ownership of ${CONDA_DIR} (owned by ${OWNER})."
130+
logger -p "install.warning" "${MSG}" || echo "${MSG}"
131+
fi
132+
fi
133+
CONDARC="${HOME}/.condarc"
134+
if [[ -f "${CONDARC}" ]]; then
135+
if ! chown "${USER}" "${CONDARC}"; then
136+
OWNER=$(stat -f "%u" "${CONDARC}" | id -un)
137+
MSG="WARNING: Unable to change ownership of ${CONDARC} (owned by ${OWNER})."
138+
logger -p "install.warning" "${MSG}" || echo "${MSG}"
139+
fi
140+
fi
127141

128142
notify "Done! Installation is available in $PREFIX."
129143

news/1185-pkg-chown-permissions

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
### Enhancements
2+
3+
* <news item>
4+
5+
### Bug fixes
6+
7+
* PKG: Do not fail the installer when ownership of files in `$HOME` cannot be changed. (#1177 via #1184)
8+
9+
### Deprecations
10+
11+
* <news item>
12+
13+
### Docs
14+
15+
* <news item>
16+
17+
### Other
18+
19+
* <news item>

0 commit comments

Comments
 (0)