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

Nanoc 4.9.2+ crashes when creating hard links on Chrome OS, running inside Termux. #1405

Closed
printfn opened this issue Feb 6, 2019 · 13 comments

Comments

Projects
None yet
2 participants
@printfn
Copy link

commented Feb 6, 2019

Nanoc 4.9.2+ crashes when creating hard links on Chrome OS, running inside Termux.

Steps to reproduce

rm -rf docs # I've renamed the output directory to 'docs'
nanoc

Expected behavior

Building the nanoc site

Actual behavior

Crash log:
https://gist.github.com/printfn/6791787b4fb0bb68c86c08b94031a6ea

Details

The issue seems to be caused by the use of hard links in nanoc 4.9.2. I can reproduce it on 4.9.2, and on the latest 4.11.0. The issue does NOT occur on 4.9.1.

I'm using an Acer Chromebook 15 (CB5-571), running nanoc through Termux from the Play Store. The environment is sandboxed, and the developer mode is disabled.

@ddfreyne

This comment has been minimized.

Copy link
Member

commented Feb 7, 2019

Hey,

I investigated this but unfortunately couldn’t find directly what is causing this. I don’t have a Chromebook device to test this out, unfortunately.

Can you do something for me, that would shed more light on the situation?

  1. Set a breakpoint in lib/nanoc/base/services/item_rep_writer.rb:53, or perhaps add sleep 120 right in front of that line to emulate a breakpoint.

  2. Right before the breakpoint (or the sleep call), add puts ">>> temp_path = #{temp_path}".

  3. Run the modified Nanoc again. You’ll see something like this in the output:

    >>> temp_path = /data/data/com.termux/files/usr/tmp/nanoc20190206-4245-mvsz4o/text_items/4
    
  4. Let me know whether the base directory (printed above) exists. Following the example above, /data/data/com.termux/files/usr/tmp/nanoc20190206-4245-mvsz4o/text_items should exist, as well as its parent directory.

  5. Let me know what the permissions are of the base directory (…/text_items).

  6. Let me know whether you can manually create a file in the directory (e.g. touch …/text_items/12345, replacing with the base directory).

Hopefully, that will give me enough information to debug this further.

@printfn

This comment has been minimized.

Copy link
Author

commented Feb 9, 2019

I tried your suggestions, with these results:

The text_items directory exists, and the files 0 to 4 also exist. These are the permissions:

$ ls -al ../../usr/tmp/nanoc20190209-2226-13g4tvj/text_items/
total 76
drwx------    2 u0_a55   u0_a55        4096 Feb  9 11:53 .
drwx------    3 u0_a55   u0_a55        4096 Feb  9 11:52 ..
-rw-------    1 u0_a55   u0_a55        6243 Feb  9 11:52 0
-rw-------    1 u0_a55   u0_a55        4472 Feb  9 11:52 1
-rw-------    1 u0_a55   u0_a55        3647 Feb  9 11:52 2
-rw-------    1 u0_a55   u0_a55        9165 Feb  9 11:52 3
-rw-------    1 u0_a55   u0_a55        4882 Feb  9 11:52 4

Manually creating a file in this directory also works, and it has default permissions of -rw-------.

@printfn

This comment has been minimized.

Copy link
Author

commented Feb 9, 2019

I also tried running:

ln ../../usr/tmp/nanoc20190209-2226-13g4tvj/text_items/4 test

This fails with ln: test: Permission denied.

On the other hand, running

ln -s ../../usr/tmp/nanoc20190209-2226-13g4tvj/text_items/4 test

succeeds, and vim test afterwards lets me edit the file.

@ddfreyne

This comment has been minimized.

Copy link
Member

commented Feb 9, 2019

Can you replace

          begin
            FileUtils.ln(temp_path, raw_path, force: true)
          rescue Errno::EXDEV
            FileUtils.cp(temp_path, raw_path)
          end

in item_rep_writer.rb, lines 62 to 66, with

          FileUtils.cp(temp_path, raw_path)

and let me know whether that works?

@printfn

This comment has been minimized.

Copy link
Author

commented Feb 9, 2019

Yes, that causes it to work.

@ddfreyne

This comment has been minimized.

Copy link
Member

commented Feb 9, 2019

OK, I think #1406 has a workaround — it falls back to not using hardlinking, which is suboptimal, but at least the desires behavior (having the right files in the right places) is there.

@printfn

This comment has been minimized.

Copy link
Author

commented Feb 9, 2019

Your patch uses EACCESS, but it should be EACCES. I've applied it now, and it fixes the bug.

@ddfreyne

This comment has been minimized.

Copy link
Member

commented Feb 9, 2019

Whoops, I thought that was a typo on my part. Fixed.

@ddfreyne

This comment has been minimized.

Copy link
Member

commented Feb 9, 2019

I found something relevant:

facebook/create-react-app#1832 (comment)

Due to Android's SELinux policies, you cannot hard link as non-root

So I suppose that copying (rather than hardlinking) is the proper fix.

@ddfreyne

This comment has been minimized.

Copy link
Member

commented Feb 9, 2019

I will merge and release Nanoc once CI has passed.

@printfn

This comment has been minimized.

Copy link
Author

commented Feb 9, 2019

Great, thanks!

@ddfreyne

This comment has been minimized.

Copy link
Member

commented Feb 9, 2019

Nanoc 4.11.1 is now released. Can you double-check to verify that this release works for you?

@printfn

This comment has been minimized.

Copy link
Author

commented Feb 9, 2019

Yes, it works with 4.11.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.