diff --git a/lib/rdoc.rb b/lib/rdoc.rb index a05391d769..2d3f8c1122 100644 --- a/lib/rdoc.rb +++ b/lib/rdoc.rb @@ -129,12 +129,15 @@ module RDoc if File.directory?(rdoc_dir) rdoc_dir else - # XDG - xdg_data_home = ENV["XDG_DATA_HOME"] || File.join(File.expand_path("~"), '.local', 'share') - unless File.exist?(xdg_data_home) - FileUtils.mkdir_p xdg_data_home + begin + # XDG + xdg_data_home = ENV["XDG_DATA_HOME"] || File.join(File.expand_path("~"), '.local', 'share') + unless File.exist?(xdg_data_home) + FileUtils.mkdir_p xdg_data_home + end + File.join xdg_data_home, "rdoc" + rescue Errno::EACCES end - File.join xdg_data_home, "rdoc" end end