Unable to create Vagrant local installation

AI 生成的摘要

vinothkannans encountered an issue when trying to install Discourse on their local Windows system using Vagrant. The error message “Could not find module pretty-text/pretty-text” appeared after running the command bundle exec rake db:migrate. The error was raised on the line == Seed from /vagrant/db/fixtures/500_lounge_category.rb.

vinothkannans provided more details on the error and suspected that the problem was caused by a require statement in the lib/pretty_text/shims.js file.

vinothkannans eventually fixed the issue themselves by submitting a pull request to the Discourse repository (https://github.com/discourse/discourse/pull/4421). The fix involved adding chomp to a Regexp to remove a weird last line character. This issue only occurred when using Vagrant on a Windows PC, and not when using Docker or a Ubuntu development environment.

I followed the instruction below to install Discourse on my local windows system

I got below error after the command bundle exec rake db:migrate

Could not find module pretty-text/pretty-text

Error raised on the line

== Seed from /vagrant/db/fixtures/500_lounge_category.rb

For more details i attached the error below

== Seed from /vagrant/db/fixtures/009_users.rb
 - User {:id=>-1, :name=>"system", :username=>"system", :username_lower=>"system", :email=>"no_email", :password=>"180b8ba3113f54b33d61a313277c4f01", :active=>true, :admin=>true, :moderator=>true, :approved=>true, :trust_level=>4}

== Seed from /vagrant/db/fixtures/500_lounge_category.rb
rake aborted!
MiniRacer::RuntimeError: Error: Could not find module pretty-text/pretty-text/nError: Could not find module pretty-text/pretty-text
JavaScript at missingModule (<anonymous>:117:11)
JavaScript at requireModule (<anonymous>:127:17)
JavaScript at <anonymous>:1:16
/home/vagrant/.rvm/gems/ruby-2.3.1/gems/mini_racer-0.1.3/lib/mini_racer.rb:99:in `eval_unsafe'
/home/vagrant/.rvm/gems/ruby-2.3.1/gems/mini_racer-0.1.3/lib/mini_racer.rb:99:in `block in eval'
/home/vagrant/.rvm/gems/ruby-2.3.1/gems/mini_racer-0.1.3/lib/mini_racer.rb:97:in `synchronize'
/home/vagrant/.rvm/gems/ruby-2.3.1/gems/mini_racer-0.1.3/lib/mini_racer.rb:97:in `eval'
/home/vagrant/.rvm/gems/ruby-2.3.1/gems/mini_racer-0.1.3/lib/mini_racer.rb:93:in `load'
/vagrant/lib/pretty_text.rb:82:in `create_es6_context'
/vagrant/lib/pretty_text.rb:105:in `block in v8'
/vagrant/lib/pretty_text.rb:103:in `synchronize'
/vagrant/lib/pretty_text.rb:103:in `v8'
/vagrant/lib/pretty_text.rb:124:in `block in markdown'
/vagrant/lib/pretty_text.rb:359:in `block in protect'
/vagrant/lib/pretty_text.rb:358:in `synchronize'
/vagrant/lib/pretty_text.rb:358:in `protect'
/vagrant/lib/pretty_text.rb:123:in `markdown'
/vagrant/lib/pretty_text.rb:211:in `cook'
/vagrant/app/models/post_analyzer.rb:17:in `cook'
/vagrant/app/models/post.rb:219:in `cook'
/vagrant/lib/post_creator.rb:203:in `before_create_tasks'
/vagrant/app/models/post.rb:480:in `block in <class:Post>'

I think the problem is raised at require statement in below file

require('pretty-text/pretty-text')

Finally I fixed it myself (check below PR). Just one line code fixed it.

https://github.com/discourse/discourse/pull/4421

Here when we use Regexp without chomp it have some weird last line char. (maybe \n). Without this change initial db migration failing always in Vagrant with == Seed from /vagrant/db/fixtures/500_lounge_category.rb.

Also I am not facing this issue in docker installation. Even in Ubuntu development guide. Only in Vagrant. Weird :imp:

Edit: File are in Windows PC. Maybe that’s the reason