Skip to content

Commit a17854f

Browse files
committed
warn user that installation will fail if she doesn't have necessary write permission
1 parent 61a627e commit a17854f

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

share/ruby-install/functions.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,22 @@ source "$ruby_install_dir/checksums.sh"
77
#
88
function pre_install()
99
{
10+
11+
local status
12+
local exisiting_part_dir="${install_dir%/*}"
13+
1014
mkdir -p "$src_dir" || return $?
11-
mkdir -p "${install_dir%/*}" || return $?
15+
16+
while [ ! -d "$exisiting_part_dir" ]; do
17+
exisiting_part_dir="${exisiting_part_dir%/*}"
18+
done
19+
20+
if [ ! -w "$exisiting_part_dir" ]; then
21+
fail "Installation directory is not writable by the user : ${exisiting_part_dir}"
22+
status=$?
23+
fi
24+
25+
mkdir -p "${install_dir%/*}" || return $status
1226
}
1327

1428
#
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
. ./test/helper.sh
4+
5+
test_install_dir="$test_fixtures_dir/no_write_permissions_test"
6+
7+
function setUp()
8+
{
9+
mkdir -p "$test_install_dir/bin"
10+
chmod -w "$test_install_dir/bin"
11+
}
12+
13+
function test_no_write_permissions()
14+
{
15+
local output status
16+
output="$(ruby-install --install-dir "$test_install_dir/bin/rubies" ruby 2>&1)"
17+
status=$?
18+
19+
assertEquals "did not return 0" 255 $status
20+
assertTrue "did not print a message to STDOUT" \
21+
'[[ "$output" == *"Installation directory is not writable by the user"* ]]'
22+
}
23+
24+
function tearDown()
25+
{
26+
rm -rf "$test_install_dir"
27+
}
28+
29+
SHUNIT_PARENT=$0 . $SHUNIT2

0 commit comments

Comments
 (0)