{"action":"created","issue":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/3116","repository_url":"https://api.github.com/repos/crystal-lang/crystal","labels_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3116/labels{/name}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3116/comments","events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3116/events","html_url":"https://github.com/crystal-lang/crystal/issues/3116","id":169989269,"number":3116,"title":"crystal-lang require question","user":{"login":"fibric","id":623932,"avatar_url":"https://avatars.githubusercontent.com/u/623932?v=3","gravatar_id":"","url":"https://api.github.com/users/fibric","html_url":"https://github.com/fibric","followers_url":"https://api.github.com/users/fibric/followers","following_url":"https://api.github.com/users/fibric/following{/other_user}","gists_url":"https://api.github.com/users/fibric/gists{/gist_id}","starred_url":"https://api.github.com/users/fibric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fibric/subscriptions","organizations_url":"https://api.github.com/users/fibric/orgs","repos_url":"https://api.github.com/users/fibric/repos","events_url":"https://api.github.com/users/fibric/events{/privacy}","received_events_url":"https://api.github.com/users/fibric/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/crystal-lang/crystal/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/crystal-lang/crystal/labels/compiler","name":"compiler","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-08-08T18:16:27Z","updated_at":"2016-08-08T18:29:38Z","closed_at":null,"body":"I have some questions regarding how `require` exactly works.\r\n\r\nI want to build an XML parser and started with `crystal init lib xml`\r\n```\r\n      create  xml/.gitignore\r\n      create  xml/LICENSE\r\n      create  xml/README.md\r\n      create  xml/.travis.yml\r\n      create  xml/shard.yml\r\n      create  xml/src/xml.cr\r\n      create  xml/src/xml/version.cr\r\n      create  xml/spec/spec_helper.cr\r\n      create  xml/spec/xml_spec.cr\r\nInitialized empty Git repository in /Users/fibric/Projects/crystal/xml/.git/\r\n```\r\nThen run `cd xml; crystal spec` or the bash/zsh version `cd xml && crystal spec`.\r\n```crystal\r\nUndefined symbols for architecture x86_64:\r\n  \"_*Xml@Object::to_s:String\", referenced from:\r\n      _*describe<Xml:Module, String, Int32, &Proc(Nil)>:Spec::Context+ in _main.o\r\nld: symbol(s) not found for architecture x86_64\r\nclang: error: linker command failed with exit code 1 (use -v to see invocation)\r\nError: execution of command failed with code: 1: `cc -o \"/Users/fibric/.cache/crystal/crystal-run-spec.tmp\" \"${@}\"  -rdynamic  -lxml2 -lpcre -lgc -lpthread /usr/local/Cellar/crystal-lang/0.18.7_1/src/ext/libcrystal.a -levent -liconv -ldl -L/usr/lib -L/usr/local/lib`\r\n```\r\n\r\nI re-tried but this time `cd ..; crystal init lib xml.cr`\r\n```\r\n      create  xml.cr/.gitignore\r\n      create  xml.cr/LICENSE\r\n      create  xml.cr/README.md\r\n      create  xml.cr/.travis.yml\r\n      create  xml.cr/shard.yml\r\n      create  xml.cr/src/xml.cr.cr\r\n      create  xml.cr/src/xml.cr/version.cr\r\n      create  xml.cr/spec/spec_helper.cr\r\n      create  xml.cr/spec/xml.cr_spec.cr\r\nInitialized empty Git repository in /Users/fibric/Projects/crystal/xml.cr/.git/\r\n```\r\nThen run `cd xml.cr; crystal spec` or the bash/zsh version `cd xml.cr && crystal spec`.\r\nIt created a folder named `xml.cr`with a file `xml.cr.cr` inside.\r\n```crystal\r\nError in line 1: while requiring \"./spec/xml.cr_spec.cr\"\r\n\r\nin ./spec/xml.cr_spec.cr:1: while requiring \"./spec_helper\"\r\n\r\nrequire \"./spec_helper\"\r\n^\r\n\r\nin ./spec/spec_helper.cr:2: while requiring \"../src/xml.cr\": Error reading file: Is a directory\r\n\r\nrequire \"../src/xml.cr\"\r\n```\r\n\r\nStrange. I couldn't find a `require.cr` file to see what's happening but here are my thoughts.\r\nIn my first attempt require tries to load `xml` from the standard library. In my second attempt require cuts of `.cr` and sees now only the folder named `xml.cr`. Am I right?\r\n\r\nI have a video\r\n[![asciicast](https://asciinema.org/a/82089.png)](https://asciinema.org/a/82089)"},"comment":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/comments/238331977","html_url":"https://github.com/crystal-lang/crystal/issues/3116#issuecomment-238331977","issue_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3116","id":238331977,"user":{"login":"asterite","id":209371,"avatar_url":"https://avatars.githubusercontent.com/u/209371?v=3","gravatar_id":"","url":"https://api.github.com/users/asterite","html_url":"https://github.com/asterite","followers_url":"https://api.github.com/users/asterite/followers","following_url":"https://api.github.com/users/asterite/following{/other_user}","gists_url":"https://api.github.com/users/asterite/gists{/gist_id}","starred_url":"https://api.github.com/users/asterite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asterite/subscriptions","organizations_url":"https://api.github.com/users/asterite/orgs","repos_url":"https://api.github.com/users/asterite/repos","events_url":"https://api.github.com/users/asterite/events{/privacy}","received_events_url":"https://api.github.com/users/asterite/received_events","type":"User","site_admin":false},"created_at":"2016-08-08T18:29:38Z","updated_at":"2016-08-08T18:29:38Z","body":"@fibric Our of curiosity, are you on a mac?"}}
{"actor":{"display_login":"asterite"}}