Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop moving Xcode with sudo #455

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/xcode/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ def install_dmg(dmg_path, suffix = '', switch = true, clean = true)
xcode_orig_path = File.join(Dir.pwd, 'Xcode.app')
xcode_beta_path = File.join(Dir.pwd, 'Xcode-beta.app')
if Pathname.new(xcode_orig_path).exist?
`sudo -p "#{prompt}" mv "#{xcode_orig_path}" "#{xcode_path}"`
`mv "#{xcode_orig_path}" "#{xcode_path}"`
elsif Pathname.new(xcode_beta_path).exist?
`sudo -p "#{prompt}" mv "#{xcode_beta_path}" "#{xcode_path}"`
`mv "#{xcode_beta_path}" "#{xcode_path}"`
else
out = <<-HELP
No `Xcode.app(or Xcode-beta.app)` found in XIP. Please remove #{dmg_path} if you
Expand All @@ -260,14 +260,14 @@ def install_dmg(dmg_path, suffix = '', switch = true, clean = true)
return
end

`sudo -p "#{prompt}" ditto "#{source}" "#{xcode_path}"`
`ditto "#{source}" "#{xcode_path}"`
`umount "/Volumes/Xcode"`
end

xcode = InstalledXcode.new(xcode_path)

unless xcode.verify_integrity
`sudo rm -rf #{xcode_path}`
`rm -rf #{xcode_path}`
return
end

Expand All @@ -276,8 +276,8 @@ def install_dmg(dmg_path, suffix = '', switch = true, clean = true)
xcode.install_components

if switch
`sudo rm -f #{SYMLINK_PATH}` unless current_symlink.nil?
`sudo ln -sf #{xcode_path} #{SYMLINK_PATH}` unless SYMLINK_PATH.exist?
`rm -f #{SYMLINK_PATH}` unless current_symlink.nil?
`ln -sf #{xcode_path} #{SYMLINK_PATH}` unless SYMLINK_PATH.exist?

`sudo xcode-select --switch #{xcode_path}`
puts `xcodebuild -version`
Expand Down Expand Up @@ -330,8 +330,8 @@ def rm_list_cache

def symlink(version)
xcode = installed_versions.find { |x| x.version == version }
`sudo rm -f #{SYMLINK_PATH}` unless current_symlink.nil?
`sudo ln -sf #{xcode.path} #{SYMLINK_PATH}` unless xcode.nil? || SYMLINK_PATH.exist?
`rm -f #{SYMLINK_PATH}` unless current_symlink.nil?
`ln -sf #{xcode.path} #{SYMLINK_PATH}` unless xcode.nil? || SYMLINK_PATH.exist?
end

def symlinks_to
Expand Down
2 changes: 1 addition & 1 deletion lib/xcode/install/uninstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def run
installed_path = @installer.installed_versions.find { |x| x.version == @version }
return if installed_path.nil? || installed_path.path.nil?

`sudo rm -rf #{installed_path.path}`
`rm -rf #{installed_path.path}`

return unless @installer.symlinks_to == installed_path.path
newest_version = @installer.installed_versions.last
Expand Down