imathis / octopress

Octopress is an obsessively designed framework for Jekyll blogging. It’s easy to configure and easy to deploy. Sweet huh?
http://github.com/imathis/octopress
9.31k stars 2.62k forks source link

Deploying to Github Pages #1015

Open lgiordani opened 11 years ago

lgiordani commented 11 years ago

I'm working behind a firewall which allows me only http and https access to Internet. Following http://octopress.org/docs/deploying/github/ I get the following

$ rake setup_github_pages
Enter the read/write url for your repository
(For example, 'git@github.com:your_username/your_username.github.com)
Repository url: https://github.com/lgiordani/lgiordani.github.com.git
rake aborted!
undefined method `[]' for nil:NilClass

Tasks: TOP => setup_github_pages
(See full trace by running task with --trace)

it runs without problems if I insert

git@github.com:lgiordani/lgiordani.github.com.git

Bu then if I run rake deploy it stucks at

## Pushing generated _deploy website

I think this is because of SSH access being forbidden from my machine. Any help?

Thank you

parkr commented 11 years ago

We've added support for this in our 2.1 branch, but it may still be a bit shaky. Try it for us and see what happens?

lgiordani commented 11 years ago

I tried with a bare repository. After cloning http://github.com/imathis/octopress.git I tracked your 2.1 branch with git checkout -t remotes/origin/2.1 and rake setup_github_pages returns

Enter the read/write url for your repository: https://github.com/lgiordani/lgiordani.github.com.git
Added remote https://github.com/lgiordani/lgiordani.github.com.git as origin
Set origin as default remote
Master branch renamed to 'source' for committing your blog source files
rm -rf _deploy
mkdir _deploy
cd _deploy
Initialized empty Git repository in /home/leo/lgiordani.github.com/_deploy/.git/
Attempting to pull from repository
fatal: Couldn't find remote ref master
Unexpected end of command stream
[master (root-commit) 4418360] Octopress init
 1 file changed, 1 insertion(+)
 create mode 100644 index.html
cd -
{:deploy_branch=>"master", :deploy_dir=>"_deploy", :copy_dot_files=>[], :deploy_default=>"push"}
rake aborted!
undefined method `has_key?' for nil:NilClass
/home/leo/lgiordani.github.com/Rakefile:428:in `block in <top (required)>'
Tasks: TOP => setup_github_pages
(See full trace by running task with --trace)

Full trace is here

** Invoke setup_github_pages (first_time)
** Execute setup_github_pages
Enter the read/write url for your repository: https://github.com/lgiordani/lgiordani.github.com.git
Added remote https://github.com/lgiordani/lgiordani.github.com.git as origin
Set origin as default remote
Master branch renamed to 'source' for committing your blog source files
rm -rf _deploy
mkdir _deploy
cd _deploy
Initialized empty Git repository in /home/leo/lgiordani.github.com/_deploy/.git/
Attempting to pull from repository
fatal: Couldn't find remote ref master
Unexpected end of command stream
[master (root-commit) 6e2dcd4] Octopress init
 1 file changed, 1 insertion(+)
 create mode 100644 index.html
cd -
{:deploy_branch=>"master", :deploy_dir=>"_deploy", :copy_dot_files=>[], :deploy_default=>"push"}
rake aborted!
undefined method `has_key?' for nil:NilClass
/home/leo/lgiordani.github.com/Rakefile:428:in `block in <top (required)>'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/var/lib/gems/1.9.1/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'
Tasks: TOP => setup_github_pages

Sorry but I know nothing about ruby so I cannot really understand what's going on.

Installing gems with bundle install installed the following

Fetching gem metadata from http://rubygems.org/........
Fetching gem metadata from http://rubygems.org/..
Installing rake (10.0.3) 
Using RedCloth (4.2.9) 
Installing chunky_png (1.2.6) 
Using fast-stemmer (1.0.1) 
Using classifier (1.3.3) 
Using fssm (0.2.9) 
Installing sass (3.2.4) 
Using compass (0.12.2) 
Using directory_watcher (1.4.1) 
Using haml (3.1.7) 
Using kramdown (0.13.8) 
Using liquid (2.3.0) 
Using syntax (1.0.0) 
Using maruku (0.6.1) 
Using posix-spawn (0.3.6) 
Using yajl-ruby (1.1.0) 
Using pygments.rb (0.3.4) 
Using jekyll (0.12.0) 
Installing jsmin (1.0.1) 
Using rack (1.4.1) 
Using rack-protection (1.3.2) 
Installing rake-minify (0.4.0) 
Installing rb-fsevent (0.9.3) 
Using rdiscount (1.6.8) 
Installing redcarpet (2.2.2) with native extensions 
Using rubypants (0.2.0) 
Using tilt (1.3.3) 
Using sinatra (1.3.3) 
Using stringex (1.4.0) 
Installing tzinfo (0.3.35) 
Using bundler (1.2.3) 

I am available to test again the whole thing, just tell me what you need. Thank you

lgiordani commented 11 years ago

I think I found the problem (see Google Groups), but I have no knowledge to write a patch.

parkr commented 11 years ago

Got it. Problem is, as you discovered:

Spotted, I think: in Rakefile:427

site_configuration = Octopress::Configuration.read_config('site.yml')

but since _config/site.yml is an empty file

---
# --------------------------- #
#   User Site Configuration   #
# --------------------------- #

the resulting site_configuration is nil, hence the

undefined method `has_key?' for nil:NilClass
lgiordani commented 11 years ago

The above issue can be solved just entering

url: 'http://yoursite.com'

in _config/_site.yml.

This is not the best way to handle the case, however. It would be best to insert the above line, but commented

# Uncomment this and set it according to your needs if you want to use a custom domain
# url: 'http://yoursite.com'

And handle in Rakefile the case of empty file.

Rakefile stops anyway because of current_url undefined (used at line 435 and 445). Moreover, I find help text from lines 443 and 446 a little inaccurate. Problems I spotted:

What do you think? Thanks

parkr commented 11 years ago

I just fixed this! If the config file (YAML file) is empty, YAML returns nil. It now returns Hash.new when there are no configs present. Ref #1005.

lgiordani commented 11 years ago

Thank you. It still does not work because of the current_url issue. See the above comment.

gregkare commented 11 years ago

The pull request above should fix this issue with the undefined current_url variable. I've also changed the comments with your suggestions @lgiordani

gregkare commented 11 years ago

There's still stuff that's going to cause problems this part of the code.

This line in the setup_github_pages task is loading explicitly the user's _config/site.yml file, and then on the next line setting the url to a generated URL (defined here).

That means that the most current case (the default), where the user hasn't yet copied _config/default/classic.yml to _config/site.yml, site_configuration[:url] is going to be nil, because we're not loading _config/default/classic.yml which contains the default value that we're checking against.

lgiordani commented 11 years ago

I think this has already been solved by @parkr with #1005. Branch 2.1 already contains an empty _config/site.yml which now does not need to be replaced by a copy of _config/defaults/classic.yml.

However I understand the issue pointed by @gkarekinian. Why do both _config/site.yml and _config/defaults/classic.yml contain the same flag? I think that probably _config/defaults/classic.yml is meant to stay there untouched (as a default, indeed), while other files in _config should overwrite its values. What is the point of this way? The only reason I see is to isolate the different parts of the old _config.yml to allow a simpler customization. I'm not totally sure that this is a good thing, however.

Parker, can you clarify the purpose and structure of the new config system?

Thanks

floydpink commented 11 years ago

I have been struggling to set up a brand new clone off of 2.1 as well, for the past few days (and hence #1006). Apart from the above findings, it also seemed to me that the branch itself needs to be called 'master' rather than '2.1' for 'setup_github_pages' to configure the 'deploy' correctly.

Can someone please explain how to setup '2.1' from scratch?

Thanks

parkr commented 11 years ago

@lgiordani The new configuration setup is meant to offer flexibility with plugins and their configurations and reduce merge conflicts. By having a user-defined set of configs (site.yml) paired with defaults, we have more flexibility to update plugins and themes more easily. When we release the next version, we'll write about it.

@gkarekinian I think defaults/classic.yml contains a nonsensical url config that would have the same outcome as loading nothing. Should work fine unless I'm overlooking something.

@floydpink On your clone, check out master and merge 2.1 into it. Then run the rake task and you should be ok!

PogiNate commented 11 years ago

So, I just merged 2.1 into master, (on a brand new clone of master) then tried this. I tried it without editing anything and that failed. So I added a url: 'http://yoursite.com' line and ran rake setup_github_pages again, and still got an error. So I copied the entire classic.yml file over to _config/site.yml and filled in all the values and it's still saying >rake aborted!

undefined local variable or method current_url' for main:Object >/Users/natedickson/Projects/Natedicksondotcom/octopress/Rakefile:512:inblock in <top (required)>'

imathis commented 11 years ago

I'm taking a look at this now.

imathis commented 11 years ago

Let me know if this works better for you now.

sheedy commented 11 years ago

I followed the steps @PogiNate mentioned (clone master then merge 2.1) but my issue is with this new config structure. It isn't making any sense to me.

What I did:

The blog is generated correctly but no Pinboard data is displayed. The /source/_includes/sidebars/blog_index_default.html includes /source/_includes/sidebars/sections/pinboard.html as expected (I just enterd dummy text on the page) but the feed is never displayed. I tested this with Github too but I think the problem is in how it's calling for the config settings. The start of /source/_includes/sidebars/sections/pinboard.html references site.pinboard_user. If I add pinboard_user to /_config/site.yml then it displays the HTML.

So if site.yml only takes values that were used in 2.0 (they all seem to work) then what are all the files in the _config/defaults/ directory for?

Also, I get missing JS errors for javascripts/pinboard.js and javascripts/octopress.js. There are coffeescript files for these but no JS is generated. The only JS files that appear in the public folder after generating are:

The js includes in the html header don't seem to match up with the assets available.

PogiNate commented 11 years ago

I discovered that if I just run rake setup_github_pages and use the git@github... address it works just fine. If I try to run the rake task with the https://github.com... address it fails. However, if I run the setup task and then change the git setup after the fact to the https:// path then rake deploy works just fine.