{"action":"created","issue":{"url":"https://api.github.com/repos/purpliminal/rust-dotenv/issues/101","repository_url":"https://api.github.com/repos/purpliminal/rust-dotenv","labels_url":"https://api.github.com/repos/purpliminal/rust-dotenv/issues/101/labels{/name}","comments_url":"https://api.github.com/repos/purpliminal/rust-dotenv/issues/101/comments","events_url":"https://api.github.com/repos/purpliminal/rust-dotenv/issues/101/events","html_url":"https://github.com/purpliminal/rust-dotenv/issues/101","id":323694098,"number":101,"title":"dotenv works differently in 'build' vs 'run' if the project is in a workspace","user":{"login":"limira","id":20672976,"avatar_url":"https://avatars3.githubusercontent.com/u/20672976?v=4","gravatar_id":"","url":"https://api.github.com/users/limira","html_url":"https://github.com/limira","followers_url":"https://api.github.com/users/limira/followers","following_url":"https://api.github.com/users/limira/following{/other_user}","gists_url":"https://api.github.com/users/limira/gists{/gist_id}","starred_url":"https://api.github.com/users/limira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/limira/subscriptions","organizations_url":"https://api.github.com/users/limira/orgs","repos_url":"https://api.github.com/users/limira/repos","events_url":"https://api.github.com/users/limira/events{/privacy}","received_events_url":"https://api.github.com/users/limira/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-05-16T16:22:47Z","updated_at":"2018-05-19T12:57:54Z","closed_at":"2018-05-19T12:57:54Z","author_association":"NONE","body":"I am actually using [`diesel`](https://github.com/diesel-rs/diesel) which is in turn relied on `dotenv`. In an app that use `diesel` and its `infer_schema!` macro, a database url is required for `diesel` to inspect the database schema. It is used like this:\r\n\r\n    infer_schema!(\"dotenv:DATABASE_URL\");\r\n\r\nIn this case, the `infer_schema!` try to load the `.env` file before getting value of `DATABASE_URL`. This works correctly in standalone projects. But with projects inside a **workspace** it does not work if the `.env` file is in the project root.\r\n```\r\nworkspace\\\r\n    |--- Cargo.toml\r\n    |--- .env // DATABASE_URL in here, it works for infer_schema!\r\n    |--- projects\\\r\n         |--- libs\\....\r\n         |--- apps\\\r\n              |--- project1\\\r\n                   |--- Cargo.toml\r\n                   |--- .env // DATABASE_URL in here, it DOES NOT work for infer_schema!\r\n                             // But work correctly in main(), see more bellow\r\n                   |--- src\\...\r\n```\r\nBut if I only use it inside main(),\r\n```\r\nfn main() {\r\n    dotenv::dotenv().ok();\r\n    let url = std::env::var(\"DATABASE_URL\").expect(\"DATABASE_URL not found\");\r\n    // No panic from the line above and `url` have correct value of DATABASE_URL\r\n}\r\n```\r\nThe `infer_schema` execute at `build` time, `main` execute at `run` time. So I think there are some inconsistency in the way `dotenv` works in `cargo build` vs `cargo run`. (Both `cargo build` and `cargo run` run inside the `project1` folder.)"},"comment":{"url":"https://api.github.com/repos/purpliminal/rust-dotenv/issues/comments/390403310","html_url":"https://github.com/purpliminal/rust-dotenv/issues/101#issuecomment-390403310","issue_url":"https://api.github.com/repos/purpliminal/rust-dotenv/issues/101","id":390403310,"user":{"login":"purpliminal","id":3437734,"avatar_url":"https://avatars0.githubusercontent.com/u/3437734?v=4","gravatar_id":"","url":"https://api.github.com/users/purpliminal","html_url":"https://github.com/purpliminal","followers_url":"https://api.github.com/users/purpliminal/followers","following_url":"https://api.github.com/users/purpliminal/following{/other_user}","gists_url":"https://api.github.com/users/purpliminal/gists{/gist_id}","starred_url":"https://api.github.com/users/purpliminal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/purpliminal/subscriptions","organizations_url":"https://api.github.com/users/purpliminal/orgs","repos_url":"https://api.github.com/users/purpliminal/repos","events_url":"https://api.github.com/users/purpliminal/events{/privacy}","received_events_url":"https://api.github.com/users/purpliminal/received_events","type":"User","site_admin":false},"created_at":"2018-05-19T12:57:54Z","updated_at":"2018-05-19T12:57:54Z","author_association":"OWNER","body":"This issue seems like a repeat of #71, and I feel like the arguments for and against this issue that were raised then still stand. I'm closing this, but feel free to reopen it if you wish to discuss it further."}}
{"actor":{"display_login":"purpliminal"}}