Beginners Guide to Install Discourse on macOS for Development

Hello, I continued the process, updated bundle using gem install bundler like recommended above and also ran:

bundle exec rake autospec which showed 333 errors:

Finished in 19 minutes 50 seconds (files took 17.48 seconds to load)
11038 examples, 333 failures, 4 pending

See screenshots attached. Any idea how to resolve this?

Did you try running db:migrate as follows ?

RAILS_ENV=test LOAD_PLUGINS=1 rake db:migrate

3 Likes

Regarding urandom issues

Try

5 Likes

Thanks @venarius and @sam. It improved a bit, now with:

Finished in 16 minutes 22 seconds (files took 15.88 seconds to load) 11038 examples, 199 failures, 4 pending

Most errors are failed to get urandom, except the first which is:

LoadError: cannot load such file -- /Users/sunyata/discourse/app/models/topic_notifier

Most failed examples are rspec. Is the first load error the cause of all these problems? Also, in the progress area, it says:

svgo worker: `svgo` not found; please provide proper binary or disable this worker (--no-svgo argument or `:svgo => false` through options)
..svgo worker: `svgo` not found; please provide proper binary or disable this worker (--no-svgo argument or `:svgo => false` through options)
.....head: illegal line count -- -500

How do you disable workers or provide the proper binary?

Thanks

For svgo you need to install node and then npm install -g svgo

4 Likes

Can someone assist me in how I can update my discourse?

/launcher rebuild app

returns an error.

./launcher rebuild app is for discourse_docker based production setup. To update local/development Discourse instance you need:

cd ~/discourse
git pull origin master
5 Likes

I get this error @techAPJ,

error: Your local changes to the following files would be overwritten by merge:
	.gitignore
Please commit your changes or stash them before you merge.
Aborting

The error message is pretty clear:

Please commit your changes or stash them before you merge.

If you want to ignore your local changes, do:

git fetch origin
git reset --hard origin/master
6 Likes

Did the tests again and got these errors. Can someone help fix this?:


Nevermind. Fixed. Reseting then reconfiguring helped fix the issues. :slight_smile:

2 Likes

I got same error when I run bundle exec rspec

[Noah Dolph]:
3) Search include_diacritics allows strips correctly
Failure/Error: expect(results.posts.length).to eq(1)
expected: 1
got: 0
(compared using ==)
# ./spec/components/search_spec.rb:1071:in …
4) Search ignore_diacritics allows strips correctly
Failure/Error: expect(results.posts.length).to eq(1)
expected: 1
got: 0
(compared using ==)
# ./spec/components/search_spec.rb:1050:in …

and this was solved after set Postgres locale to C

I’m adding detail for someone who get this error.

When I check Postgres query result,

the result was different. so, rspec failed:

SELECT TO_TSVECTOR('simple', 'hello');
=> 'hello':1

SELECT TO_TSVECTOR('simple', 'สวัสดี');
=>

And locale was not set as C

]$psql -l
                                        List of databases
           Name           |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
--------------------------+----------+----------+-------------+-------------+-----------------------
 discourse_test           | hangu    | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 ...

Changed locale to C

When install and init Postgres by the Postgres.app,
I didn’t click init button. instead ran below command:

bin/initdb --locale=C -E UTF-8 -D ~/Library/Application\ Support/Postgres/var-11

and checked locale:

]$psql -l
                          List of databases
   Name    | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------+----------+---------+-------+-------------------
 postgres  | hangu | UTF8     | C       | C     |
 template0 | hangu | UTF8     | C       | C     | =c/hangu         +
           |       |          |         |       | hangu=CTc/hangu
 template1 | hangu | UTF8     | C       | C     | =c/hangu         +
           |       |          |         |       | hangu=CTc/hangu
(3 rows)

the query result:

SELECT TO_TSVECTOR('simple', 'hello');
=> 'hello':1

SELECT TO_TSVECTOR('simple', 'สวัสดี');
=> 'สวัสดี':1

and rspec passed.

Hi,

How can i upgrade Discourse version?

I always run git pull && gem install bundler && bundle install && bundle exec rake db:migrate

6 Likes

bundle exec rails server output:

INFO – : Refreshing Gem list
Discourse requires Ruby 2.5.2 or up

That means you need to upgrade Ruby to a newer version.

3 Likes

I am already installed Ruby via Homebrew. My Ruby version is 2.6.

I tried the solution you referenced:

> launchctl limit maxfiles
maxfiles    64000          524288 

But I’m still getting a bunch of urandom errors when I run the tests:

32) Report topic report with topics returns today's data
  Failure/Error: self.salt = SecureRandom.hex(16)

  RuntimeError:
    failed to get urandom
  # ./app/models/user.rb:1313:in `ensure_password_is_hashed'

I haven’t found any other clues on how to solve it or why it might be happening. Everything else seems to be working (I can access Discourse on localhost:3000).
For what it’s worth, I’m running Mojave 10.14.6 with Postgres 11.5 (from Homebrew)

I don’t think Postgres 11 is supported by Discourse. We plan to upgrade to 12 soon.

PG 11 should work fine for local dev, only big issue is if you need to take a database backup from dev and upload it to production.

This is this issue:

https://bugs.ruby-lang.org/issues/14716

Try:

cat /dev/urandom is that returning anything? If that is not working then you need to figure out how to sort that out on your mac.

3 Likes