{"id":23131413,"url":"https://github.com/mcjkula/lua-dotenv","last_synced_at":"2026-03-11T02:01:34.605Z","repository":{"id":267817399,"uuid":"859876234","full_name":"mcjkula/lua-dotenv","owner":"mcjkula","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-19T14:07:41.000Z","size":8,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-16T00:27:45.595Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcjkula.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-19T12:39:28.000Z","updated_at":"2025-04-11T15:25:02.000Z","dependencies_parsed_at":"2024-12-12T16:37:37.112Z","dependency_job_id":"15d7597d-b282-4902-91b7-445cb84631da","html_url":"https://github.com/mcjkula/lua-dotenv","commit_stats":null,"previous_names":["mcjkula/lua-dotenv"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mcjkula/lua-dotenv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcjkula%2Flua-dotenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcjkula%2Flua-dotenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcjkula%2Flua-dotenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcjkula%2Flua-dotenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcjkula","download_url":"https://codeload.github.com/mcjkula/lua-dotenv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcjkula%2Flua-dotenv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30367799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T21:41:54.280Z","status":"online","status_checked_at":"2026-03-11T02:00:07.027Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-17T11:13:04.708Z","updated_at":"2026-03-11T02:01:34.584Z","avatar_url":"https://github.com/mcjkula.png","language":"Lua","readme":"# Lua-Dotenv\n\nlua-dotenv is a simple Lua module that allows you to load environment variables from a .env file into your Lua environment. It provides an easy way to manage configuration in your Lua projects.\n\n## Features\n\n- Load environment variables from a .env file\n- Access environment variables with fallback default values\n- Simple and lightweight implementation\n- Compatible with Lua 5.1 and above\n\n## Requirements\n\n- Lua \u003e= 5.1\n\n## Installation\n\nUsing LuaRocks:\n\n```luarocks install lua-dotenv```\n\n## Usage\n\n1. Create a .env file:\n\nBy default, lua-dotenv looks for the .env file in `~/.config/.env`. You can also specify a custom location when loading the file.\n\nExample .env file content:\n\n```lua\nDATABASE_URL=postgresql://user:password@localhost:5432/mydb\nDEBUG=true\nMAX_CONNECTIONS=100\n```\n\n2. In your Lua script:\n\n```lua\nlocal dotenv = require(\"lua-dotenv\")\n```\n\n-- Load variables from default .env file location (`~/.config/.env`)\n```lua\ndotenv.load_dotenv()\n```\n\n-- Or, specify a custom .env file location\n-- `dotenv.load_dotenv(\"/path/to/your/.env\")`\n\n-- Access environment variables\n```lua\nlocal db_url = dotenv.get(\"DATABASE_URL\")\nlocal debug_mode = dotenv.get(\"DEBUG\")\nlocal max_conn = dotenv.get(\"MAX_CONNECTIONS\", \"50\")  -- \"50\" is the default value\n\nprint(\"Database URL:\", db_url)\nprint(\"Debug mode:\", debug_mode)\nprint(\"Max connections:\", max_conn)\n```\n\n## Functions\n\n- `dotenv.load_dotenv(file_path)`: Loads environment variables from the specified file path. If no path is provided, it defaults to ~/.config/.env.\n- `dotenv.get(key, default)`: Retrieves the value of the environment variable specified by key. If the variable is not set, it returns the default value.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcjkula%2Flua-dotenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcjkula%2Flua-dotenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcjkula%2Flua-dotenv/lists"}