Created
October 30, 2019 00:03
-
-
Save jfonte/a27948cbd4cdcbadd308e9fb47cf1139 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
VAGRANTFILE_API_VERSION = "2" | |
REQUIRED_PLUGINS = %w(vagrant-vbguest) | |
plugins_to_install = REQUIRED_PLUGINS.select { |plugin| not Vagrant.has_plugin? plugin } | |
if not plugins_to_install.empty? | |
puts "Installing required plugins: #{plugins_to_install.join(' ')}" | |
if system "vagrant plugin install #{plugins_to_install.join(' ')}" | |
exec "vagrant #{ARGV.join(' ')}" | |
else | |
abort "Installation of one or more plugins has failed. Aborting. Please read the Bike Index README." | |
end | |
end | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "ubuntu/xenial64" | |
# Forward the Rails server default port to the host | |
config.vm.network :forwarded_port, guest: 3000, host: 3000 | |
#### Provision #### | |
config.vm.provision "shell" do |script| | |
script.path = "install-rails.sh" | |
end | |
# Configure the virtual machine to use 1.5GB of RAM | |
config.vm.provider :virtualbox do |vb| | |
vb.customize ["modifyvm", :id, "--memory", "1536"] | |
end | |
# create sync folder for VM and local directory | |
config.vm.synced_folder ".", "/home/vagrant/",type:"virtualbox" | |
# TODO provisioning config or use chef | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Troubelshooting FAQ
Installing Vagrant for Rails dev (applies mostly to Windows 10)
source: https://gorails.com/guides/using-vagrant-for-rails-development
vagrant plugin install vagrant-vbguest
cd MY_RAILS_PROJECT # Change this to your Rails project directory
vagrant init
troubleshooting
1) "An error occurred while installing pg (1.1.4), and Bundler cannot continue."
-> try this:
2) error An unexpected error occurred: "EPROTO: protocol error, symlink '../../../../js-yaml/bin/js-yaml.js' -> '/home/vagrant/cross_sell/node_modules/@rails/webpacker/node_modules/.bin/js-yaml'".
-> this seems to be caused by vagrantfs or Windows 10 security policies. There are two possible fixes for this:
(a) temp. fix, run:
sudo yarn install --no-bin-links
(b) correct long term fix, give permission to the user that is running
vagrant up
to use symlinks.Just update your policies:
https://superuser.com/a/725998
You can create symbolic links like this:
Your user account has some security policies on them by default which can be disabled, through secpol.msc. Go to the Run dialog and type:
When you log back in, run cmd with admin privileges. Now you should be able to run mklink commands like this with no problems:
Note: Make sure the directory you're trying to link to exists or hasn't been moved or deleted, prior to linking."
source: yarnpkg/yarn#4908
3) error "PG::InsufficientPrivilege: ERROR: permission denied" when running rails DB:setup
Add 'superuser' privileges to 'vagrant' via psql
4) if you run
rails s
and get "Listen error: unable to monitor directories for changes"-> echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
source: https://stackoverflow.com/questions/42225677/listen-error-unable-to-monitor-directories-for-changes
5) ETXTBSY error when running yarn
-> temp fix, run:
source: laravel/homestead#922
6) can't connect to localhost:3000 ?
run rails like so or create an alias:
"rails s -b 0.0.0.0"
7) role "vagrant" does not exist
add vagrant user to postgres
sudo su - postgres
createuser vagrant -s
exit