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

Test failure: Error resolving real path of 'spec/std/data/test_file.txt' #8547

Closed
ndbroadbent opened this issue Dec 3, 2019 · 7 comments · Fixed by #9296
Closed

Test failure: Error resolving real path of 'spec/std/data/test_file.txt' #8547

ndbroadbent opened this issue Dec 3, 2019 · 7 comments · Fixed by #9296

Comments

@ndbroadbent
Copy link

Hello! I cloned the crystal repo (up to commit 54e68f0), and ran all of the tests with make spec. I got one test failure:

Using /usr/local/opt/llvm@8/bin/llvm-config [version=8.0.1]
.build/all_spec
...
Failures:

  1) File symlink creates a symbolic link

       Error resolving real path of 'spec/std/data/test_file.txt': No such file or directory (Errno)
         from src/crystal/system/unix/file.cr:92:5 in 'real_path'
         from src/file.cr:559:5 in 'real_path'
         from spec/std/file_spec.cr:247:22 in '->'
         from src/spec/example.cr:255:3 in 'internal_run'
         from src/spec/example.cr:35:16 in 'run'
         from src/spec/context.cr:296:23 in 'internal_run'
         from src/spec/context.cr:291:7 in 'run'
         from src/spec/context.cr:296:23 in 'internal_run'
         from src/spec/context.cr:291:7 in 'run'
         from src/spec/context.cr:48:23 in 'run'
         from src/spec/dsl.cr:270:7 in '->'
         from src/kernel.cr:255:3 in 'run'
         from src/crystal/main.cr:47:5 in 'main'
         from src/crystal/main.cr:106:3 in 'main'


Finished in 38:47 minutes
18312 examples, 0 failures, 1 errors, 17 pending

Failed examples:

crystal spec spec/std/file_spec.cr:244 # File symlink creates a symbolic link
make: *** [spec] Error 1
  • macOS 10.15.1
$ .build/crystal --version
Crystal 0.32.0-dev [54e68f0b3] (2019-12-02)

LLVM: 8.0.1
Default target: x86_64-apple-macosx
@rdp
Copy link
Contributor

rdp commented Dec 3, 2019

related to #8431 ? Sometimes I wonder if crystal --version could output more info like openssl version, OS version... :)

@ndbroadbent
Copy link
Author

@rdp yes that looks like it!

I would like to try this to see if it fixes the issue:

I think this is caused by the new security features introduced in Catatonia. If you open System Preferences>Privacy>Full Disk Access, and add the Julia application to the list of ‘approved’ apps, these start to work again. Might be wrong... 😀

But I'm struggling to figure out how to run a single spec.

$ crystal spec spec/std/file_spec.cr:243
Showing last frame. Use --error-trace for full trace.

In spec/std/file_spec.cr:585:12

 585 | File.expand_path("~/", home: true).should eq(File.join(home, ""))
            ^----------
Error: no argument named 'home'

Matches are:
 - File.expand_path(path, dir = nil)

Do you know how I can just run that one spec in the Crystal test suite?

@asterite
Copy link
Member

asterite commented Dec 3, 2019

You need to use bin/crystal instead of crystal.

There's a bit more info here: https://github.com/crystal-lang/crystal/blob/master/CONTRIBUTING.md#the-standard-library (it might be outdated, I'm not sure)

@ndbroadbent
Copy link
Author

ndbroadbent commented Dec 3, 2019

Ah thanks, yes that was it! I set up an alias so I don't forget that again:

~/code/crystal $ alias crystal="CRYSTAL_BIN=\$([ -f ./bin/crystal ] && echo ./bin/crystal || echo \$(which crystal)); \$CRYSTAL_BIN"
~/code/crystal $ crystal --version
Using compiled compiler at .build/crystal
Crystal 0.32.0-dev [54e68f0b3] (2019-12-02)

LLVM: 8.0.1
Default target: x86_64-apple-macosx
~/code/crystal $ cd ..
~/code/ $ crystal --version
Crystal 0.31.1 (2019-10-02)

LLVM: 8.0.1
Default target: x86_64-apple-macosx

@ndbroadbent
Copy link
Author

ndbroadbent commented Dec 3, 2019

I wanted to see if there might be an automated way to fix this issue on Mac, so I found out that these file permissions are managed in /Library/Application Support/com.apple.TCC/TCC.db. However, this file is protected by SIP, so it's read-only unless you boot into recovery mode (even with sudo.) FWIW, I figured out the SQL query that would work if it was writable:

BIN_PATH="$HOME/code/crystal/.build/crystal"

sudo sqlite3 \
  "/Library/Application Support/com.apple.TCC/TCC.db" \
  "INSERT INTO access (service, client, client_type, allowed, \
    prompt_count, indirect_object_identifier, flags) VALUES(\
    'kTCCServiceSystemPolicyAllFiles', \
    '$BIN_PATH', \
    1, 1, 1, 'UNUSED', 0);"

So I went to System Preferences => Security & Privacy => Privacy => Full Disk Access. Then clicked the lock icon to make changes. Then I clicked "+" to add a new app, and navigated to my crystal source code folder. Then I needed to press ⌘ + Shift + . to show the hidden .build folder, and selected .build/crystal.

Unfortunately that didn't fix the spec! I tried again with the bin/crystal wrapper script, but that also didn't work. Also no luck with sudo ./bin/crystal spec spec/std/file_spec.cr:243.

So I'm not sure what else to try! This is how Julia fixed the issue: Replace realpath implementation with libuv

@ndbroadbent
Copy link
Author

ndbroadbent commented Dec 3, 2019

I just saw this comment in gitter:

@chuanshuo crystal used to use libuv, but it then migrate to libevent. If I recall right, it was faster / lighter to use libevent that libuv. But asterite and waj are more aware of that story. I think that when using libuv inlining assembly was not an option. Today it is and the context switch is lighter also because of that. But I might be skipping some facts in the whole story.

EDIT: Here's another relevant discussion on the deepmind/lab project: google-deepmind/lab#173

@jwoertink
Copy link
Contributor

@ndbroadbent If you want to run a single spec, you can either do

it "does stuff", focus: true do

end

or run the spec file with the line number

crystal spec spec/some_file.cr:355

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants