{"record":{"id":"7c13a93a3cc1884b","repo":"spatie/laravel-permission","slug":"teams-feature-disabled-argument-team-id-has-no-7c13a9","errorCode":null,"errorMessage":"Teams feature disabled, argument --team-id has no effect. Either enable it in permissions config file or remove --team-id parameter","messagePattern":"Teams feature disabled, argument --team-id has no effect\\. Either enable it in permissions config file or remove --team-id parameter","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/Commands/CreateRoleCommand.php","lineNumber":29,"sourceCode":"class CreateRoleCommand extends Command\n{\n    protected $signature = 'permission:create-role\n        {name : The name of the role}\n        {guard? : The name of the guard}\n        {permissions? : A list of permissions to assign to the role, separated by | }\n        {--team-id=}';\n\n    protected $description = 'Create a role';\n\n    public function handle(PermissionRegistrar $permissionRegistrar): int\n    {\n        $roleClass = app(RoleContract::class);\n\n        $teamIdAux = getPermissionsTeamId();\n        setPermissionsTeamId($this->option('team-id') ?: null);\n\n        if (! $permissionRegistrar->teams && $this->option('team-id')) {\n            $this->warn('Teams feature disabled, argument --team-id has no effect. Either enable it in permissions config file or remove --team-id parameter');\n\n            return self::SUCCESS;\n        }\n\n        $role = $roleClass::findOrCreate($this->argument('name'), $this->argument('guard'));\n        setPermissionsTeamId($teamIdAux);\n\n        $teams_key = $permissionRegistrar->teamsKey;\n        if ($permissionRegistrar->teams && $this->option('team-id') && is_null($role->$teams_key)) {\n            $this->warn(\"Role `{$role->name}` already exists on the global team; argument --team-id has no effect\");\n        }\n\n        $role->givePermissionTo($this->makePermissions($this->argument('permissions')));\n\n        $this->info(\"Role `{$role->name}` \".($role->wasRecentlyCreated ? 'created' : 'updated'));\n\n        return self::SUCCESS;\n    }","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/spatie/laravel-permission/blob/afd24018f68306e8b43ace487c107a59af1be776/src/Commands/CreateRoleCommand.php#L11-L47","documentation":"The permission:create-role command accepts a --team-id option that is only honored when the teams feature is enabled (PermissionRegistrar::$teams, driven by config('permission.teams')). When teams is off but --team-id was passed, the command prints this warning and returns SUCCESS immediately — the role is NOT created and no permissions are attached. The early return prevents creating a role that would silently ignore the requested team scope. Note the command also sets the permissions team id from --team-id before this check, so running it in-process can leak team context even though creation is skipped.","triggerScenarios":"Running `php artisan permission:create-role writer web \"perm1|perm2\" --team-id=X` while config('permission.teams') is false. Any truthy --team-id value together with the disabled feature hits the early return before findOrCreate() runs.","commonSituations":"Same command reused across environments where only some have teams enabled; a seeder/deploy script carrying --team-id from a multi-tenant phase of the project; teams turned off in config while old documentation or scripts still pass the flag.","solutions":["Remove the --team-id option: php artisan permission:create-role writer web \"edit posts\"","If you really want team-scoped roles, enable teams: set 'teams' => true in config/permission.php, run php artisan permission:setup-teams, migrate, then re-run the command with --team-id","Confirm the live flag with `php artisan tinker` → config('permission.teams') and clear the config cache (php artisan config:clear) after edits"],"exampleFix":"# before\nphp artisan permission:create-role writer web \"edit posts\" --team-id=2\n# exits 0 with the warning; no role created\n\n# after (teams disabled)\nphp artisan permission:create-role writer web \"edit posts\"","handlingStrategy":"validation","validationCode":"// skip --team-id unless the feature is actually on\n$teamsEnabled = app(\\Spatie\\Permission\\PermissionRegistrar::class)->teams;\n$options = ($teamsEnabled && $teamId) ? ['--team-id' => $teamId] : [];\n\\Illuminate\\Support\\Facades\\Artisan::call('permission:create-role', [\n    'name' => 'writer',\n    'guard' => 'web',\n    'permissions' => 'edit posts',\n] + $options);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass --team-id only when config('permission.teams') is true","This path exits 0 without creating the role — seeders should assert Role::exists() afterwards instead of trusting the exit code","Audit provisioning scripts for stale --team-id flags whenever the teams feature is toggled"],"tags":["laravel","artisan","spatie-permission","teams","cli","configuration"],"backgroundTag":"feature-flag-disabled","analyzedSha":"afd24018f68306e8b43ace487c107a59af1be776","analyzedAt":"2026-08-21T01:13:42.706Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}