Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Install and usage #13

Open
therebelrobot opened this issue Apr 19, 2016 · 13 comments
Open

Docs: Install and usage #13

therebelrobot opened this issue Apr 19, 2016 · 13 comments

Comments

@therebelrobot
Copy link

So I forked the repo and wanted to take a look at some of the frontend styling, but couldn't find any docs for install / usage. I'm largely unfamiliar with ruby (I do have it installed though, ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]), but I do want to get it started locally to work on it. Any tips?

@tracykm
Copy link
Owner

tracykm commented Apr 19, 2016

Good point! I'll work on an installation guide.

But in the meantime here are the steps (as far as I remember) to get it running if you already have Ruby and PostgreSQL installed:

install the gems:

bundle install

make sure PostgreSQL is running (I open the application, I assume there is also a command line way)
node modules

npm install

set up and seed the database

rake db:setup

set up webpack to continuously bundle files

webpack —watch

open a new tab and start the server with:

rails server

it should now be running on localhost:3000

Let me know if this works for you, it's a hard to simulate setting it for the first time to be sure.

@therebelrobot
Copy link
Author

Do you have a way of specifying the PostgreSQL location on run, maybe through an environment variable? I don't run it on localhost, rather in a docker container (ends up being http://192.168.99.100:5432)

@therebelrobot
Copy link
Author

Also, thanks a million! With those docs alone I'll be able to get a lot further than where I got before 🚀

@therebelrobot
Copy link
Author

Here's what I tried:

sudo gem install bundler
bundle install # see bundle error feeback below
npm install

After those commands, I edited config/database.yml:40 & :44 to set my dockered postgres. Then I tried:

rake db:setup

but it returned another error. See rake db:setup error feedback below.

Bundle Error Feedback

On bundle install, I received the following error amidst the success logs:

Installing pg 0.18.4 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /private/var/folders/h1/359yc4x92xl6kt8ht1063dj40000gn/T/bundler20160421-28068-1cwzi5pg-0.18.4/gems/pg-0.18.4/ext
/usr/local/opt/ruby/bin/ruby -r ./siteconf20160421-28068-1wec83d.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/Cellar/ruby/2.3.0/bin/$(RUBY_BASE_NAME)
    --with-pg
    --without-pg
    --enable-windows-cross
    --disable-windows-cross
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/folders/h1/359yc4x92xl6kt8ht1063dj40000gn/T/bundler20160421-28068-1cwzi5pg-0.18.4/extensions/x86_64-darwin-15/2.3.0/pg-0.18.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/folders/h1/359yc4x92xl6kt8ht1063dj40000gn/T/bundler20160421-28068-1cwzi5pg-0.18.4/gems/pg-0.18.4 for inspection.
Results logged to /var/folders/h1/359yc4x92xl6kt8ht1063dj40000gn/T/bundler20160421-28068-1cwzi5pg-0.18.4/extensions/x86_64-darwin-15/2.3.0/pg-0.18.4/gem_make.out

At the end of that install, it printed:

An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.4'` succeeds before bundling.

Upon running that command, the same error as above was printed.

rake db:setup Error Feedback

Could not find activesupport-4.2.5 in any of the sources
Run `bundle install` to install missing gems.

@therebelrobot
Copy link
Author

So found this:

http://stackoverflow.com/questions/6040583/cant-find-the-libpq-fe-h-header-when-trying-to-install-pg-gem

Which directed me to run brew install postgresql. I think because I have postgres in docker it didn't have the native extensions needed to connect it, even remotely. After doing the above, I ran bundle install without error.

@therebelrobot
Copy link
Author

So with some tweaking, I got most of the errors to shutup. One error is eluding me, though, when running rake db:setup:

rake db:setup                                                                                                                                      (node-5.10.1) [10:13:38]
-- enable_extension("plpgsql")
NOTICE:  extension "plpgsql" already exists, skipping
   -> 0.0148s
-- create_table("books", {:force=>:cascade})
   -> 0.0067s
-- create_table("likes", {:force=>:cascade})
   -> 0.0057s
-- add_index("likes", ["liker_id", "poem_id"], {:name=>"index_likes_on_liker_id_and_poem_id", :unique=>true, :using=>:btree})
   -> 0.0033s
-- add_index("likes", ["liker_id"], {:name=>"index_likes_on_liker_id", :using=>:btree})
   -> 0.0034s
-- add_index("likes", ["poem_id"], {:name=>"index_likes_on_poem_id", :using=>:btree})
   -> 0.0033s
-- create_table("poems", {:force=>:cascade})
   -> 0.0040s
-- add_index("poems", ["author_id"], {:name=>"index_poems_on_author_id", :using=>:btree})
   -> 0.0033s
-- add_index("poems", ["book_id"], {:name=>"index_poems_on_book_id", :using=>:btree})
   -> 0.0030s
-- add_index("poems", ["style_id"], {:name=>"index_poems_on_style_id", :using=>:btree})
   -> 0.0028s
-- create_table("selected_texts", {:force=>:cascade})
   -> 0.0038s
-- add_index("selected_texts", ["poem_id"], {:name=>"index_selected_texts_on_poem_id", :using=>:btree})
   -> 0.0034s
-- create_table("styles", {:force=>:cascade})
   -> 0.0043s
-- add_index("styles", ["background_id"], {:name=>"index_styles_on_background_id", :using=>:btree})
   -> 0.0029s
-- add_index("styles", ["font_set_id"], {:name=>"index_styles_on_font_set_id", :using=>:btree})
   -> 0.0027s
-- create_table("users", {:force=>:cascade})
   -> 0.0044s
-- add_index("users", ["session_token"], {:name=>"index_users_on_session_token", :unique=>true, :using=>:btree})
   -> 0.0042s
-- add_index("users", ["username"], {:name=>"index_users_on_username", :unique=>true, :using=>:btree})
   -> 0.0030s
-- initialize_schema_migrations_table()
   -> 0.0214s
-- enable_extension("plpgsql")
NOTICE:  extension "plpgsql" already exists, skipping
   -> 0.0130s
-- create_table("books", {:force=>:cascade})
   -> 0.0056s
-- create_table("likes", {:force=>:cascade})
   -> 0.0038s
-- add_index("likes", ["liker_id", "poem_id"], {:name=>"index_likes_on_liker_id_and_poem_id", :unique=>true, :using=>:btree})
   -> 0.0033s
-- add_index("likes", ["liker_id"], {:name=>"index_likes_on_liker_id", :using=>:btree})
   -> 0.0030s
-- add_index("likes", ["poem_id"], {:name=>"index_likes_on_poem_id", :using=>:btree})
   -> 0.0035s
-- create_table("poems", {:force=>:cascade})
   -> 0.0044s
-- add_index("poems", ["author_id"], {:name=>"index_poems_on_author_id", :using=>:btree})
   -> 0.0030s
-- add_index("poems", ["book_id"], {:name=>"index_poems_on_book_id", :using=>:btree})
   -> 0.0034s
-- add_index("poems", ["style_id"], {:name=>"index_poems_on_style_id", :using=>:btree})
   -> 0.0026s
-- create_table("selected_texts", {:force=>:cascade})
   -> 0.0035s
-- add_index("selected_texts", ["poem_id"], {:name=>"index_selected_texts_on_poem_id", :using=>:btree})
   -> 0.0025s
-- create_table("styles", {:force=>:cascade})
   -> 0.0042s
-- add_index("styles", ["background_id"], {:name=>"index_styles_on_background_id", :using=>:btree})
   -> 0.0030s
-- add_index("styles", ["font_set_id"], {:name=>"index_styles_on_font_set_id", :using=>:btree})
   -> 0.0031s
-- create_table("users", {:force=>:cascade})
   -> 0.0043s
-- add_index("users", ["session_token"], {:name=>"index_users_on_session_token", :unique=>true, :using=>:btree})
   -> 0.0030s
-- add_index("users", ["username"], {:name=>"index_users_on_username", :unique=>true, :using=>:btree})
   -> 0.0026s
-- initialize_schema_migrations_table()
   -> 0.0062s
rake aborted!
NoMethodError: undefined method `update' for nil:NilClass
/Users/therebelrobot/git/opensource/Poemist/db/seeds.rb:13:in `<top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
/usr/local/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `block in load'
/usr/local/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
/usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:547:in `load_seed'
/usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/tasks/database_tasks.rb:250:in `load_seed'
/usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/railties/databases.rake:183:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:setup => db:seed
(See full trace by running task with --trace)

Doing research. Will update this thread when I find more.

@therebelrobot
Copy link
Author

Ah, looks like it's an error on rake db:seed too. is seed run automatically after setup?

@therebelrobot
Copy link
Author

therebelrobot commented Apr 21, 2016

Commenting out db/seeds.rb:10-13 and :23-26 looks to have made it happy. I guess it was trying to update before creating.

EDIT: So I commented in everything except the find_by calls, and it seems to have worked with more data.

@therebelrobot
Copy link
Author

therebelrobot commented Apr 21, 2016

Sooooo close. On rails server, I get the following error:

rails server
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/path_support.rb:50:in `split_gem_path': undefined method `split' for #<Array:0x007f8f339bd628> (NoMethodError)
    from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/path_support.rb:32:in `initialize'
    from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems.rb:351:in `new'
    from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems.rb:351:in `paths='
    from /Users/therebelrobot/git/opensource/Poemist/bin/spring:11:in `<top (required)>'
    from bin/rails:3:in `load'
    from bin/rails:3:in `<main>'

EDIT: The only local file it points to seems to be bin/spring:11 which is:

Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq }

research:

rails/spring#456

rails/spring#458

@therebelrobot
Copy link
Author

As per rails/spring#456, I changed Gemfile:57 to read:

gem 'spring', github: 'sonalkr132/spring', branch: 'bundler-dep'

And the server seems to start. 🚀

@therebelrobot
Copy link
Author

For all that is good and holy; I hate rails. After running rails server -p <port-number> I finally see the app:

sorry for the email/thread spam, thought it'd be good to document this journey though.

therebelrobot added a commit to therebelrobot/Poemist that referenced this issue Apr 21, 2016
@tracykm
Copy link
Owner

tracykm commented Apr 21, 2016

Definitely. It's like I'm half way to set up documentation already :)

Yay!! I'm so glad you have it set up. No overt your eyes and don't look at any of the horrible code I wrote with no one to keep me in check or make me explain myself. Jajaja

@therebelrobot
Copy link
Author

lolol. no worries. I'll try and clean up as I go, but I'm planning on, at the very least, hopping in and getting those mobile views tightened up.

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

No branches or pull requests

2 participants