Skip to content

Comments

refactor get_host_ip method to use route for host IP detection#20

Open
pollardld wants to merge 1 commit intomainfrom
update-vagrantfile
Open

refactor get_host_ip method to use route for host IP detection#20
pollardld wants to merge 1 commit intomainfrom
update-vagrantfile

Conversation

@pollardld
Copy link
Member

Updates the Vagrantfile to use a more robust get_host_ip method. Increases the likely hood of only one IP address being returned, bc more than one causes a vagrant error that looks like:

Failed to mount folders in Linux guest. This is usually because the "vboxsf" file system is not available. Please verify that the guest additions are properly installed in the guest and can work properly. 

The command attempted was: mount -t cifs -o sec=ntlmssp,nounix,noperm,credentials=/etc/smb_creds_vgt-4a82863d8d3fe61c5cc456cafda2a689-ac1b791f827cf72cc7e905345947e259,uid=1000,gid=1000,mfsymlinks,_netdev,vers=3.0 //169.254.13.159 192.168.86.131/vgt-4a82863d8d3fe61c5cc456cafda2a689-ac1b791f827cf72cc7e905345947e259 /usr/local/apps/madrona_portal 

The error output from the last command was: 

mount: //169.254.13.159: can't find in /etc/fstab. bash: line 6: 192.168.86.131/vgt-4a82863d8d3fe61c5cc456cafda2a689-ac1b791f827cf72cc7e905345947e259: No such file or directory

@pollardld pollardld self-assigned this Feb 10, 2026
Copilot AI review requested due to automatic review settings February 10, 2026 20:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the host IP autodetection used by the Vagrantfile (macOS/QEMU path) to reduce cases where multiple host IPs are detected and SMB synced-folder mounting fails.

Changes:

  • Replace ifconfig | grep ... host IP detection with a route-based approach to pick the default-route interface.
  • Update inline comments describing the new detection pipeline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +5 to +9
# This uses `route` to find the host's default IP address
# and pipes it through to `awk` and `ifconfig`
# to extract the IP address of the host machine.
host_ip = `route -n get default | awk '/interface:/{print $2}' | xargs ifconfig | awk '/inet / {print $2}'`.strip

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command can still produce multiple IPv4 addresses for the chosen interface (e.g., if the interface has aliases), and .strip won’t collapse internal newlines—so host_ip may contain multiple lines and still trigger the SMB mount error this change is trying to avoid. Consider using a command that guarantees a single address (e.g., ipconfig getifaddr <iface> on macOS) or explicitly selecting/filtering one address (first line and excluding 169.254/loopback), and handle the empty-output case with a clear failure message.

Suggested change
# This uses `route` to find the host's default IP address
# and pipes it through to `awk` and `ifconfig`
# to extract the IP address of the host machine.
host_ip = `route -n get default | awk '/interface:/{print $2}' | xargs ifconfig | awk '/inet / {print $2}'`.strip
# This uses `route` to find the host's default network interface
# and then `ipconfig getifaddr` to get a single IPv4 address
# for that interface on macOS.
interface = `route -n get default | awk '/interface:/{print $2}'`.strip
host_ip = ""
unless interface.empty?
host_ip = `ipconfig getifaddr #{interface}`.strip
end
if host_ip.nil? || host_ip.empty?
raise "Unable to determine host IP address for SMB mount. Please configure smb_host_ip manually in the Vagrantfile."
end

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +6
# This uses `route` to find the host's default IP address
# and pipes it through to `awk` and `ifconfig`
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s trailing whitespace at the end of these comment lines; please remove it to avoid churn in diffs and whitespace-only changes.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants