bacongravy / macinbox

Puts macOS in a Vagrant box
Other
662 stars 45 forks source link

ENOENT errors when creating files #50

Closed frankosterfeld closed 4 years ago

frankosterfeld commented 4 years ago

With many files the create_image_from_installer.rb script creates, I get errors such as

Errno::ENOENT: No such file or directory @ rb_sysopen - /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/create_image_from_installer.ntCenXvd/scratch_mountpoint/private/etc/sudoers.d/vagrant

It works when I add explicit FileUtils.mkdir_p calls that create the directory before writing the file, like this:

+        FileUtils.mkdir_p "#{@scratch_mountpoint}/Library/LaunchDaemons/"
         File.write first_boot_launch_daemon, <<~EOF

As everyone else should run into these, I wonder if something is wrong in my environment.

I'm on macOS Catalina 10.15.4, ruby --version:

 ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
bacongravy commented 4 years ago

@frankosterfeld Thanks for reporting the issue. When I've seen this kind of error in the past it was because the OS install hadn't actually worked properly, so the scratch_mounpoint was empty. Creating the missing directories (using mkdir_p) would make the step succeed, but I wouldn't expect it to produce a working box. Are you saying that the resulting vagrant box was bootable after you made the aforementioned change?

I haven't tested with a 10.15.4 installer yet, so it is possible that something has changed in what gets installed. I'll take a look.

frankosterfeld commented 4 years ago

Yep, scratch_mountpoint is indeed (almost) empty:

total 0 -rw-r--r-- 1 root wheel 0 31 Mar 10:23 .macinbox

I'm calling

sudo bundle exec macinbox --no-fullscreen --memory 4096 --disk 256 --name test --password test --installer /Applications/Install\ macOS\ Catalina.app
frankosterfeld commented 4 years ago

installer seems to be indeed silently failing, see the output log:

/usr/sbin/installer -verboseR -dumplog -pkg "/Applications/Install macOS Catalina.app/Contents/SharedSupport/InstallInfo.plist" -target ~/temp/foo

installer.log InstallInfo.plist.zip

bacongravy commented 4 years ago

Thanks for digging deeper, @frankosterfeld. This looks suspect:

Mar 31 10:55:42 installer[60670] : Couldn't mount the payload dmg ((null)): Error Domain=com.apple.osinstall Code=-34 "An error occurred while loading the installer resources." UserInfo={NSLocalizedDescription=An error occurred while loading the installer resources.}

My first thought is that maybe your installer app is corrupted somehow. Or it could be that something changed in 10.15.4. I will try to reproduce.

frankosterfeld commented 4 years ago

I deleted and redownloaded the installer app (using "GET" in the app store), I still get the same error.

frankosterfeld commented 4 years ago

I can mount the InstallESD.dmg just fine when doing it manually via open.

I wonder if ": Installer Info install requested but we're not dmg booted" is relevant, as it's the first actual "".

frankosterfeld commented 4 years ago

D'oh, I think the error above is bogus and a result of me not passing a valid disk image to --target. the actual error is mundane out of disk space error. I'll provide a patch to improve the error handling/output... Sorry for the noise.

frankosterfeld commented 4 years ago

51 together with --verbose should do the trick here.

bacongravy commented 4 years ago

@frankosterfeld I'm glad you got this figured out, and thank you for the patch!