Problem upgrading nanoc

93 views
Skip to first unread message

ahochan

unread,
Feb 20, 2012, 9:43:18 PM2/20/12
to nanoc
Hi,

I just tried to update nanoc on my Windows 7 computer by executing
"gem update nanoc"

It failed with the following error message:

Updating installed gems
Updating nanoc
ERROR: While executing gem ... (ArgumentError)
invalid byte sequence in Windows-31J

After this, it is no longer possible to run. For instance, running
"nanoc -v" results in the following error:

C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc3-3.1.7/lib/nanoc3/cli/
base.rb:5:in `<m
odule:CLI>': uninitialized constant Cri::Base (NameError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc3-3.1.7/lib/
nanoc3/cli/bas
e.rb:3:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc3-3.1.7/lib/
nanoc3/cli.rb:
12:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc3-3.1.7/bin/
nanoc3:9:in `<
top (required)>'
from C:/Ruby192/bin/nanoc3:19:in `load'
from C:/Ruby192/bin/nanoc3:19:in `<main>'

Any ideas?

Denis Defreyne

unread,
Feb 21, 2012, 2:46:13 PM2/21/12
to na...@googlegroups.com
Hi,

The nanoc -v problem is because nanoc wasn’t upgraded but its dependency (cri) was upgraded and nanoc 3.1.x requires cri 1.x, not the 2.x which was installed. But that would be irrelevant if nanoc would install properly.

Can you change the encoding used in cmd.exe to UTF-8? It is what nanoc uses (and it is the only good encoding :P). To change it, try “chcp 65001” before upgrading nanoc. Does that work? You will likely have to do that every time you use nanoc in a new cmd.exe window (there are probably ways to automate this, but I am no Windows expert).

Cheers,

Denis

> --
> You received this message because you are subscribed to the nanoc discusssion group.
>
> To post to this group, send email to na...@googlegroups.com
> To unsubscribe from this group, send email to
> nanoc+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nanoc?hl=en

signature.asc

ahochan

unread,
Feb 21, 2012, 9:47:54 PM2/21/12
to nanoc
Thanks... setting the code page to UTF-8 worked!

Is there an overview somewhere of incompatibilities with older nanoc
code?

The following doesn't compile, it complains about "@item[:limit] ||=
10"

def prepare_feed(params)
# Extract parameters
@item[:limit] ||= 10
@item[:articles] = @site.sorted_articles[0, 10]
#@item[:articles] = params[:articles] || latest_articles(10) || []
@item[:content_proc] = params[:content_proc] || lambda { |a|
a.reps[0].content_at_snapshot(:pre)}
@item[:excerpt_proc] = params[:excerpt_proc] || lambda { |a|
a[:excerpt] }
@item[:author_uri] ||= @site.config[:base_url]
@item[:author_name] ||= @site.config[:author_name]
raise RuntimeError.new('Cannot build feed: site configuration has no
base_url') if @site.config[:base_url].nil?
raise RuntimeError.new('Cannot build feed: feed item has no title')
if @item[:title].nil?
raise RuntimeError.new('Cannot build feed: no articles') if
@item[:articles].empty?
raise RuntimeError.new('Cannot build feed: one or more articles doesn
\'t have a date') if @item[:articles].any? { |a| a[:created_at].nil? }
@item[:last] = @item[:articles].first
end

Here's the output:

Loading site data...
Compiling site...
create [0.42s] output/about/index.html

Captain! We’ve been hit!

=== MESSAGE:

RuntimeError: can't modify frozen hash
You attempted to modify immutable data. Some data, such as item/layout
attribute
s and raw item/layout content, can not be modified once compilation
has started.
(This was unintentionally possible in 3.1.x and before, but has been
disabled i
n 3.2.x in order to allow compiler optimisations.)

=== COMPILATION STACK:

(empty)

=== BACKTRACE:

0. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/base/
source_data/
item.rb:201:in `[]='
1. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/base/
source_data/
item.rb:201:in `[]='
2. lib/default.rb:32:in `prepare_feed'
3. lib/default.rb:86:in `atom_feed'
4. item /atom/ (rep default):1:in `get_binding'
5. C:/Ruby192/lib/ruby/1.9.1/erb.rb:753:in `eval'
6. C:/Ruby192/lib/ruby/1.9.1/erb.rb:753:in `result'
7. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/filters/
erb.rb:34
:in `run'
8. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/base/
result_data/
item_rep.rb:344:in `filter'
9. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/base/
compilation/
item_rep_proxy.rb:47:in `filter'
10. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/base/
compilation
/rule_context.rb:54:in `filter'
11. ./Rules:15:in `block in load'
12. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/base/
compilation
/rule.rb:68:in `instance_eval'
13. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/base/
compilation
/rule.rb:68:in `apply_to'
14. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/base/
compilation
/compiler.rb:379:in `compile_rep'
15. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/base/
compilation
/compiler.rb:332:in `block in compile_reps'
16. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/base/
compilation
/compiler.rb:325:in `loop'
17. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/base/
compilation
/compiler.rb:325:in `compile_reps'
18. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/base/
compilation
/compiler.rb:85:in `run'
19. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/base/
source_data
/site.rb:57:in `compile'
20. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/cli/
commands/com
pile.rb:57:in `run'
21. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/cli/
command_runn
er.rb:14:in `block in call'
22. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/cli/
error_handle
r.rb:42:in `handle_while'
23. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/cli/
error_handle
r.rb:23:in `handle_while'
24. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/cli/
command_runn
er.rb:13:in `call'
25. C:/Ruby192/lib/ruby/gems/1.9.1/gems/cri-2.2.0/lib/cri/
command_dsl.rb:175:i
n `block in runner'
26. C:/Ruby192/lib/ruby/gems/1.9.1/gems/cri-2.2.0/lib/cri/command.rb:
291:in `c
all'
27. C:/Ruby192/lib/ruby/gems/1.9.1/gems/cri-2.2.0/lib/cri/command.rb:
291:in `r
un_this'
28. C:/Ruby192/lib/ruby/gems/1.9.1/gems/cri-2.2.0/lib/cri/command.rb:
244:in `r
un'
29. C:/Ruby192/lib/ruby/gems/1.9.1/gems/cri-2.2.0/lib/cri/command.rb:
257:in `r
un'
30. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/cli.rb:
44:in `bl
ock in run'
31. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/cli/
error_handle
r.rb:42:in `handle_while'
32. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/cli/
error_handle
r.rb:23:in `handle_while'
33. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/cli.rb:
41:in `ru
n'
34. C:/Ruby192/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/bin/nanoc:19:in
`<top (req
uired)>'
35. C:/Ruby192/bin/nanoc:19:in `load'
36. C:/Ruby192/bin/nanoc:19:in `<main>'

=== VERSION INFORMATION:

nanoc 3.3.1 (c) 2007-2012 Denis Defreyne.
Running ruby 1.9.2 (2011-02-18) on i386-mingw32 with RubyGems 1.5.2.

If you believe this is a bug in nanoc, please do report it at
<https://github.com/ddfreyne/nanoc/issues/new>--thanks!

On Feb 22, 4:46 am, Denis Defreyne <denis.defre...@stoneship.org>
wrote:
>  signature.asc
> < 1KViewDownload

Denis Defreyne

unread,
Feb 22, 2012, 12:58:34 AM2/22/12
to na...@googlegroups.com
On 22 Feb 2012, at 03:47, ahochan wrote:

> Is there an overview somewhere of incompatibilities with older nanoc code?

In general, there are no incompatibilities inside one major version, which means that sites created with any 3.x.x version are compiled with any 3.y.y version (e.g. a 3.0.0 site can be compiled with 3.3.1).

Unfortunately, I had to make one exception and that was to make data immutable during compilation. I always intended it to be that way and even in versions where it is possible, modifying data at runtime could cause subtly incorrect behavior.

> The following doesn't compile, it complains about "@item[:limit] ||= 10" [..]

You can (and should) do the feed preparation in a preprocessor block. Something like this should work:

preprocess do
def prepare_feed(item, params)
item[…] ||= …
end

params = {}
prepare_feed(@items.find { |i| i.identifier == '/feed/' }, params)
end

Cheers,

Denis

signature.asc

ahochan

unread,
Feb 29, 2012, 3:46:08 AM2/29/12
to nanoc
Is there anything special I need to include for preprocess?

I just get:
NoMethodError: undefined method `preprocess' for main:Object


On Feb 22, 2:58 pm, Denis Defreyne <denis.defre...@stoneship.org>
wrote:
>  signature.asc
> < 1KViewDownload

ahochan

unread,
Mar 2, 2012, 12:41:56 AM3/2/12
to nanoc
Forget my previous question, it was just me being silly (I've put the
code in Rules now).




I managed to get a bit further, and the preprocess section compiles.




Now I get a compile error at the first of these lines:




xml.rss(:version => '2.0') do
xml.channel do
xml.title @item[:title]




  0. lib/default.rb:59:in `block (2 levels) in rss_feed'
  1. C:/Ruby192/lib/ruby/gems/1.9.1/gems/builder-3.0.0/lib/builder/
xmlbase.rb:15
5:in `call'
  2. C:/Ruby192/lib/ruby/gems/1.9.1/gems/builder-3.0.0/lib/builder/
xmlbase.rb:15
5:in `_nested_structures'
  3. C:/Ruby192/lib/ruby/gems/1.9.1/gems/builder-3.0.0/lib/builder/
xmlbase.rb:63
:in `method_missing'
  4. lib/default.rb:56:in `block in rss_feed'
  5. C:/Ruby192/lib/ruby/gems/1.9.1/gems/builder-3.0.0/lib/builder/
xmlbase.rb:15
5:in `call'
  6. C:/Ruby192/lib/ruby/gems/1.9.1/gems/builder-3.0.0/lib/builder/
xmlbase.rb:15
5:in `_nested_structures'
  7. C:/Ruby192/lib/ruby/gems/1.9.1/gems/builder-3.0.0/lib/builder/
xmlbase.rb:63
:in `method_missing'
  8. lib/default.rb:55:in `rss_feed'

Denis Defreyne

unread,
Mar 2, 2012, 2:30:24 AM3/2/12
to na...@googlegroups.com
Hi,

Can you share your lib/default.rb file as well as the error you’re getting? You’ve given the backtrace but not the exception itself. Without those details, I can’t get an idea of what is going wrong.

Cheers,

Denis

signature.asc
Reply all
Reply to author
Forward
0 new messages