{"action":"created","comment":{"url":"https://api.github.com/repos/tarantool/tarantool/pulls/comments/283147627","pull_request_review_id":236426050,"id":283147627,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI4MzE0NzYyNw==","diff_hunk":"@@ -44,6 +44,26 @@ tarantool_exit(int);\n \n local fio = require(\"fio\")\n \n+local function sourcepath()","path":"src/lua/init.lua","position":4,"original_position":4,"commit_id":"5951e3b50cca7905f7ee2da5174325c6e3c21460","original_commit_id":"5951e3b50cca7905f7ee2da5174325c6e3c21460","user":{"login":"Totktonada","id":92749,"node_id":"MDQ6VXNlcjkyNzQ5","avatar_url":"https://avatars1.githubusercontent.com/u/92749?v=4","gravatar_id":"","url":"https://api.github.com/users/Totktonada","html_url":"https://github.com/Totktonada","followers_url":"https://api.github.com/users/Totktonada/followers","following_url":"https://api.github.com/users/Totktonada/following{/other_user}","gists_url":"https://api.github.com/users/Totktonada/gists{/gist_id}","starred_url":"https://api.github.com/users/Totktonada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Totktonada/subscriptions","organizations_url":"https://api.github.com/users/Totktonada/orgs","repos_url":"https://api.github.com/users/Totktonada/repos","events_url":"https://api.github.com/users/Totktonada/events{/privacy}","received_events_url":"https://api.github.com/users/Totktonada/received_events","type":"User","site_admin":false},"body":"I think `path` is unclear in whether it is a path to a file or to a directory.","created_at":"2019-05-12T18:09:05Z","updated_at":"2019-05-12T18:33:30Z","html_url":"https://github.com/tarantool/tarantool/pull/4193#discussion_r283147627","pull_request_url":"https://api.github.com/repos/tarantool/tarantool/pulls/4193","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/tarantool/tarantool/pulls/comments/283147627"},"html":{"href":"https://github.com/tarantool/tarantool/pull/4193#discussion_r283147627"},"pull_request":{"href":"https://api.github.com/repos/tarantool/tarantool/pulls/4193"}}},"pull_request":{"url":"https://api.github.com/repos/tarantool/tarantool/pulls/4193","id":274724459,"node_id":"MDExOlB1bGxSZXF1ZXN0Mjc0NzI0NDU5","html_url":"https://github.com/tarantool/tarantool/pull/4193","diff_url":"https://github.com/tarantool/tarantool/pull/4193.diff","patch_url":"https://github.com/tarantool/tarantool/pull/4193.patch","issue_url":"https://api.github.com/repos/tarantool/tarantool/issues/4193","number":4193,"state":"open","locked":false,"title":"Let user define application root for packages","user":{"login":"RunsFor","id":2008930,"node_id":"MDQ6VXNlcjIwMDg5MzA=","avatar_url":"https://avatars2.githubusercontent.com/u/2008930?v=4","gravatar_id":"","url":"https://api.github.com/users/RunsFor","html_url":"https://github.com/RunsFor","followers_url":"https://api.github.com/users/RunsFor/followers","following_url":"https://api.github.com/users/RunsFor/following{/other_user}","gists_url":"https://api.github.com/users/RunsFor/gists{/gist_id}","starred_url":"https://api.github.com/users/RunsFor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RunsFor/subscriptions","organizations_url":"https://api.github.com/users/RunsFor/orgs","repos_url":"https://api.github.com/users/RunsFor/repos","events_url":"https://api.github.com/users/RunsFor/events{/privacy}","received_events_url":"https://api.github.com/users/RunsFor/received_events","type":"User","site_admin":false},"body":"**Intro**:\r\n\r\nBy default, Lua uses package.path/cpath to load dependencies when user\r\ncalls `require(\"something\")`. It also allows to add custom loaders to\r\nextend its functionality. Tarantool transforms default behavior by\r\ninjecting some custom loaders into `package.loaders`.\r\n\r\nFirstly, it allows to load modules from CWD. Secondly, it looks for\r\nrocks modules starting from CWD and traversing up to root \"/\"\r\ndirectory. This \"start from CWD\" behaviour is hardcoded and not\r\ncustomizable.\r\n\r\n**Problem**:\r\n\r\nLet say we have a lua app with all dependencies under myapp directory.\r\nIf you start your application like this, you won't be able to load any\r\nof them:\r\n\r\n```\r\n$ tarantool myapp/init.lua\r\n```\r\n\r\nTo allow user scripts require dependencies relatively, user has to do\r\nlots of manipulations with debug module in order to determine current\r\nfile path and then patch package.path/cpath with both modules and rocks\r\npaths.\r\n\r\n**Solution**:\r\n\r\nIntroduce the notion of application root which is used as base for rocks\r\nand module loaders. Let user easily set this path to control how\r\napplication dependencies are loaded.\r\n\r\nWhat this patch does:\r\n\r\n1. `package.approot(path)` function sets application root which is used\r\nas root directory to load dependencies from. If path is nil, it simply\r\nreturns current app root (fio.cwd, if app root was not defined);\r\n\r\n2. `package.sourcepath()` function returns the path of the current file in\r\nwhich function was called;\r\n\r\n3. Two more loaders which loads dependencies relatively to the\r\napplication root;\r\n\r\n4. Rocks loaders now first check if application root is setup and\r\ntraverse upwards starting from it. If not, CWD is used as application\r\nroot.\r\n\r\nWith that said user is now able to achive his goal by simple call:\r\n\r\n```\r\n$ tarantool myapp/init.lua\r\n> package.approot(package.sourcepath())\r\n```\r\n\r\nIt sets application root to the path (absolute path) of the init.lua\r\nfile.","created_at":"2019-04-30T13:10:01Z","updated_at":"2019-05-12T18:33:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59ec09c46dde1d4bb90521e588b89448e327df07","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/tarantool/tarantool/pulls/4193/commits","review_comments_url":"https://api.github.com/repos/tarantool/tarantool/pulls/4193/comments","review_comment_url":"https://api.github.com/repos/tarantool/tarantool/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tarantool/tarantool/issues/4193/comments","statuses_url":"https://api.github.com/repos/tarantool/tarantool/statuses/5951e3b50cca7905f7ee2da5174325c6e3c21460","head":{"label":"RunsFor:runsfor/gh-relative-path-loaders","ref":"runsfor/gh-relative-path-loaders","sha":"5951e3b50cca7905f7ee2da5174325c6e3c21460","user":{"login":"RunsFor","id":2008930,"node_id":"MDQ6VXNlcjIwMDg5MzA=","avatar_url":"https://avatars2.githubusercontent.com/u/2008930?v=4","gravatar_id":"","url":"https://api.github.com/users/RunsFor","html_url":"https://github.com/RunsFor","followers_url":"https://api.github.com/users/RunsFor/followers","following_url":"https://api.github.com/users/RunsFor/following{/other_user}","gists_url":"https://api.github.com/users/RunsFor/gists{/gist_id}","starred_url":"https://api.github.com/users/RunsFor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RunsFor/subscriptions","organizations_url":"https://api.github.com/users/RunsFor/orgs","repos_url":"https://api.github.com/users/RunsFor/repos","events_url":"https://api.github.com/users/RunsFor/events{/privacy}","received_events_url":"https://api.github.com/users/RunsFor/received_events","type":"User","site_admin":false},"repo":{"id":177191282,"node_id":"MDEwOlJlcG9zaXRvcnkxNzcxOTEyODI=","name":"tarantool","full_name":"RunsFor/tarantool","private":false,"owner":{"login":"RunsFor","id":2008930,"node_id":"MDQ6VXNlcjIwMDg5MzA=","avatar_url":"https://avatars2.githubusercontent.com/u/2008930?v=4","gravatar_id":"","url":"https://api.github.com/users/RunsFor","html_url":"https://github.com/RunsFor","followers_url":"https://api.github.com/users/RunsFor/followers","following_url":"https://api.github.com/users/RunsFor/following{/other_user}","gists_url":"https://api.github.com/users/RunsFor/gists{/gist_id}","starred_url":"https://api.github.com/users/RunsFor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RunsFor/subscriptions","organizations_url":"https://api.github.com/users/RunsFor/orgs","repos_url":"https://api.github.com/users/RunsFor/repos","events_url":"https://api.github.com/users/RunsFor/events{/privacy}","received_events_url":"https://api.github.com/users/RunsFor/received_events","type":"User","site_admin":false},"html_url":"https://github.com/RunsFor/tarantool","description":"Get your data in RAM. Get compute close to data. Enjoy the performance.","fork":true,"url":"https://api.github.com/repos/RunsFor/tarantool","forks_url":"https://api.github.com/repos/RunsFor/tarantool/forks","keys_url":"https://api.github.com/repos/RunsFor/tarantool/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RunsFor/tarantool/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RunsFor/tarantool/teams","hooks_url":"https://api.github.com/repos/RunsFor/tarantool/hooks","issue_events_url":"https://api.github.com/repos/RunsFor/tarantool/issues/events{/number}","events_url":"https://api.github.com/repos/RunsFor/tarantool/events","assignees_url":"https://api.github.com/repos/RunsFor/tarantool/assignees{/user}","branches_url":"https://api.github.com/repos/RunsFor/tarantool/branches{/branch}","tags_url":"https://api.github.com/repos/RunsFor/tarantool/tags","blobs_url":"https://api.github.com/repos/RunsFor/tarantool/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RunsFor/tarantool/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RunsFor/tarantool/git/refs{/sha}","trees_url":"https://api.github.com/repos/RunsFor/tarantool/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RunsFor/tarantool/statuses/{sha}","languages_url":"https://api.github.com/repos/RunsFor/tarantool/languages","stargazers_url":"https://api.github.com/repos/RunsFor/tarantool/stargazers","contributors_url":"https://api.github.com/repos/RunsFor/tarantool/contributors","subscribers_url":"https://api.github.com/repos/RunsFor/tarantool/subscribers","subscription_url":"https://api.github.com/repos/RunsFor/tarantool/subscription","commits_url":"https://api.github.com/repos/RunsFor/tarantool/commits{/sha}","git_commits_url":"https://api.github.com/repos/RunsFor/tarantool/git/commits{/sha}","comments_url":"https://api.github.com/repos/RunsFor/tarantool/comments{/number}","issue_comment_url":"https://api.github.com/repos/RunsFor/tarantool/issues/comments{/number}","contents_url":"https://api.github.com/repos/RunsFor/tarantool/contents/{+path}","compare_url":"https://api.github.com/repos/RunsFor/tarantool/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RunsFor/tarantool/merges","archive_url":"https://api.github.com/repos/RunsFor/tarantool/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RunsFor/tarantool/downloads","issues_url":"https://api.github.com/repos/RunsFor/tarantool/issues{/number}","pulls_url":"https://api.github.com/repos/RunsFor/tarantool/pulls{/number}","milestones_url":"https://api.github.com/repos/RunsFor/tarantool/milestones{/number}","notifications_url":"https://api.github.com/repos/RunsFor/tarantool/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RunsFor/tarantool/labels{/name}","releases_url":"https://api.github.com/repos/RunsFor/tarantool/releases{/id}","deployments_url":"https://api.github.com/repos/RunsFor/tarantool/deployments","created_at":"2019-03-22T18:31:28Z","updated_at":"2019-04-23T08:22:44Z","pushed_at":"2019-05-07T15:47:25Z","git_url":"git://github.com/RunsFor/tarantool.git","ssh_url":"git@github.com:RunsFor/tarantool.git","clone_url":"https://github.com/RunsFor/tarantool.git","svn_url":"https://github.com/RunsFor/tarantool","homepage":"http://www.tarantool.org","size":72639,"stargazers_count":0,"watchers_count":0,"language":"Lua","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tarantool:master","ref":"master","sha":"22db9c264c9119d19a3130e6ad8e7fded0e16c6d","user":{"login":"tarantool","id":2344919,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNDQ5MTk=","avatar_url":"https://avatars0.githubusercontent.com/u/2344919?v=4","gravatar_id":"","url":"https://api.github.com/users/tarantool","html_url":"https://github.com/tarantool","followers_url":"https://api.github.com/users/tarantool/followers","following_url":"https://api.github.com/users/tarantool/following{/other_user}","gists_url":"https://api.github.com/users/tarantool/gists{/gist_id}","starred_url":"https://api.github.com/users/tarantool/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarantool/subscriptions","organizations_url":"https://api.github.com/users/tarantool/orgs","repos_url":"https://api.github.com/users/tarantool/repos","events_url":"https://api.github.com/users/tarantool/events{/privacy}","received_events_url":"https://api.github.com/users/tarantool/received_events","type":"Organization","site_admin":false},"repo":{"id":911980,"node_id":"MDEwOlJlcG9zaXRvcnk5MTE5ODA=","name":"tarantool","full_name":"tarantool/tarantool","private":false,"owner":{"login":"tarantool","id":2344919,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNDQ5MTk=","avatar_url":"https://avatars0.githubusercontent.com/u/2344919?v=4","gravatar_id":"","url":"https://api.github.com/users/tarantool","html_url":"https://github.com/tarantool","followers_url":"https://api.github.com/users/tarantool/followers","following_url":"https://api.github.com/users/tarantool/following{/other_user}","gists_url":"https://api.github.com/users/tarantool/gists{/gist_id}","starred_url":"https://api.github.com/users/tarantool/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarantool/subscriptions","organizations_url":"https://api.github.com/users/tarantool/orgs","repos_url":"https://api.github.com/users/tarantool/repos","events_url":"https://api.github.com/users/tarantool/events{/privacy}","received_events_url":"https://api.github.com/users/tarantool/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/tarantool/tarantool","description":"Get your data in RAM. Get compute close to data. Enjoy the performance.","fork":false,"url":"https://api.github.com/repos/tarantool/tarantool","forks_url":"https://api.github.com/repos/tarantool/tarantool/forks","keys_url":"https://api.github.com/repos/tarantool/tarantool/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tarantool/tarantool/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tarantool/tarantool/teams","hooks_url":"https://api.github.com/repos/tarantool/tarantool/hooks","issue_events_url":"https://api.github.com/repos/tarantool/tarantool/issues/events{/number}","events_url":"https://api.github.com/repos/tarantool/tarantool/events","assignees_url":"https://api.github.com/repos/tarantool/tarantool/assignees{/user}","branches_url":"https://api.github.com/repos/tarantool/tarantool/branches{/branch}","tags_url":"https://api.github.com/repos/tarantool/tarantool/tags","blobs_url":"https://api.github.com/repos/tarantool/tarantool/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tarantool/tarantool/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tarantool/tarantool/git/refs{/sha}","trees_url":"https://api.github.com/repos/tarantool/tarantool/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tarantool/tarantool/statuses/{sha}","languages_url":"https://api.github.com/repos/tarantool/tarantool/languages","stargazers_url":"https://api.github.com/repos/tarantool/tarantool/stargazers","contributors_url":"https://api.github.com/repos/tarantool/tarantool/contributors","subscribers_url":"https://api.github.com/repos/tarantool/tarantool/subscribers","subscription_url":"https://api.github.com/repos/tarantool/tarantool/subscription","commits_url":"https://api.github.com/repos/tarantool/tarantool/commits{/sha}","git_commits_url":"https://api.github.com/repos/tarantool/tarantool/git/commits{/sha}","comments_url":"https://api.github.com/repos/tarantool/tarantool/comments{/number}","issue_comment_url":"https://api.github.com/repos/tarantool/tarantool/issues/comments{/number}","contents_url":"https://api.github.com/repos/tarantool/tarantool/contents/{+path}","compare_url":"https://api.github.com/repos/tarantool/tarantool/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tarantool/tarantool/merges","archive_url":"https://api.github.com/repos/tarantool/tarantool/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tarantool/tarantool/downloads","issues_url":"https://api.github.com/repos/tarantool/tarantool/issues{/number}","pulls_url":"https://api.github.com/repos/tarantool/tarantool/pulls{/number}","milestones_url":"https://api.github.com/repos/tarantool/tarantool/milestones{/number}","notifications_url":"https://api.github.com/repos/tarantool/tarantool/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tarantool/tarantool/labels{/name}","releases_url":"https://api.github.com/repos/tarantool/tarantool/releases{/id}","deployments_url":"https://api.github.com/repos/tarantool/tarantool/deployments","created_at":"2010-09-15T07:59:26Z","updated_at":"2019-05-12T07:41:51Z","pushed_at":"2019-05-12T17:49:52Z","git_url":"git://github.com/tarantool/tarantool.git","ssh_url":"git@github.com:tarantool/tarantool.git","clone_url":"https://github.com/tarantool/tarantool.git","svn_url":"https://github.com/tarantool/tarantool","homepage":"http://www.tarantool.org","size":63245,"stargazers_count":2146,"watchers_count":2146,"language":"Lua","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":210,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":772,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":210,"open_issues":772,"watchers":2146,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tarantool/tarantool/pulls/4193"},"html":{"href":"https://github.com/tarantool/tarantool/pull/4193"},"issue":{"href":"https://api.github.com/repos/tarantool/tarantool/issues/4193"},"comments":{"href":"https://api.github.com/repos/tarantool/tarantool/issues/4193/comments"},"review_comments":{"href":"https://api.github.com/repos/tarantool/tarantool/pulls/4193/comments"},"review_comment":{"href":"https://api.github.com/repos/tarantool/tarantool/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tarantool/tarantool/pulls/4193/commits"},"statuses":{"href":"https://api.github.com/repos/tarantool/tarantool/statuses/5951e3b50cca7905f7ee2da5174325c6e3c21460"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Totktonada"}}